connectionMgr/inc/pingThread.h File Reference

Check whether IDS server can be reached. More...

#include <gtk/gtk.h>
#include <glib.h>
#include <liberregxml/erregapi.h>

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ping_thread_parms

Enumerations

enum  ping_status_t { PING_IDLE = 0, PING_RUNNING, PING_ABORTING, PING_UNDEFINED }

Functions

gboolean pingThread_start (ping_thread_parms *ping_parms)
gboolean pingThread_stop (void)
gboolean pingThread_wait (int timeout_sec)
gboolean pingThread_stopped (void)


Detailed Description

Check whether IDS server can be reached.

Copyright (C) 2007 iRex Technologies BV.

Definition in file pingThread.h.


Enumeration Type Documentation

Enumerator:
PING_IDLE 
PING_RUNNING 
PING_ABORTING 
PING_UNDEFINED 

Definition at line 33 of file pingThread.h.

00034         {
00035             PING_IDLE = 0,   // ping-thread not running
00036             PING_RUNNING,    // ping-thread started and connecting to server
00037             PING_ABORTING,   // ping-thread running but not wanted anymore
00038             PING_UNDEFINED
00039         } ping_status_t;


Function Documentation

gboolean pingThread_start ( ping_thread_parms ping_parms  ) 

Definition at line 199 of file pingThread.c.

00200 {
00201     GThread* thread = NULL;
00202     GError*  error = NULL;
00203 
00204     CN_LOGPRINTF("entry");
00205     if (g_ping_thread)
00206     {
00207         CN_ERRORPRINTF("ping thread already running");
00208         return FALSE;
00209     }
00210 
00211     // create the ping thread
00212     g_ping_abort = FALSE;
00213     thread = g_thread_create(pingThread, ping_parms, FALSE, &error);
00214     if (error != NULL)
00215     {
00216         CN_ERRORPRINTF("Failed to create ping thread - %s [%d]", 
00217                        error->message, error->code);
00218         g_free(error);
00219         error = NULL;
00220     }
00221     else
00222     {
00223         g_ping_thread = thread;
00224     }
00225 
00226     return TRUE;
00227 }

Here is the call graph for this function:

gboolean pingThread_stop ( void   ) 

Definition at line 230 of file pingThread.c.

00231 {
00232     CN_LOGPRINTF("entry");
00233 
00234     if (g_ping_thread)
00235     {
00236         // stop the ping thread
00237         g_ping_abort = TRUE;
00238 
00239         // stop connect action, when running
00240         connect_enable_network_abort();
00241 
00242         // stop any process spawned by pingThread
00243         pid_t pid = get_forkexec_child_pid();
00244         if (pid > 0)
00245         {
00246             kill(pid, SIGTERM);
00247         }
00248 
00249         return TRUE;
00250     }
00251     else
00252     {
00253         CN_ERRORPRINTF("ping thread not running");
00254         return FALSE;
00255     }
00256 }

Here is the call graph for this function:

gboolean pingThread_stopped ( void   ) 

Definition at line 282 of file pingThread.c.

00283 {
00284     CN_LOGPRINTF("entry");
00285 
00286     if (g_ping_thread)
00287     {
00288         return FALSE;
00289     }
00290     else
00291     {
00292         return TRUE;
00293     }
00294 }

gboolean pingThread_wait ( int  timeout_sec  ) 

Definition at line 259 of file pingThread.c.

00260 {
00261     int max_ticks = 2 * timeout_sec;
00262 
00263     CN_LOGPRINTF("entry");
00264     
00265     if (g_ping_thread)
00266     {
00267         // sorry don't like busy-wait, 
00268         // but g_thread_join has no timeout option
00269         while (g_ping_thread  &&  --max_ticks >= 0)
00270         {
00271             g_usleep(500*1000L);
00272         }
00273         return TRUE;
00274     }
00275     else
00276     {
00277         CN_ERRORPRINTF("ping thread not running");
00278         return FALSE;
00279     }
00280 }


Generated on Sun Dec 14 17:15:50 2008 by  doxygen 1.5.6