pcshareMgr/inc/sharethread.h File Reference

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

Go to the source code of this file.

Functions

gboolean shareThread_start (shareMgr_t *share_parms)
gboolean shareThread_stop (void)
gboolean shareThread_wait (int timeout_sec)


Function Documentation

gboolean shareThread_start ( shareMgr_t share_parms  ) 

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 237 of file sharethread.c.

00238 {
00239     GThread* thread = NULL;
00240     GError*  error = NULL;
00241 
00242     DL_LOGPRINTF("entry");
00243     if (g_share_thread)
00244     {
00245         DL_ERRORPRINTF("share thread already running");
00246         return FALSE;
00247     }
00248 
00249     // create the share thread
00250     g_share_abort = FALSE;
00251     thread = g_thread_create(shareThread, share_parms, FALSE, &error);
00252     if (error != NULL)
00253     {
00254         DL_ERRORPRINTF("Failed to create share thread - %s [%d]", error->message, error->code);
00255         g_free(error);
00256         error = NULL;
00257     }
00258     else
00259     {
00260         g_share_thread = thread;
00261     }
00262 
00263     return TRUE;
00264 }

Here is the call graph for this function:

gboolean shareThread_stop ( void   ) 

Definition at line 266 of file sharethread.c.

00267 {
00268     DL_LOGPRINTF("entry");
00269 
00270     if (g_share_thread)
00271     {
00272         // stop the share thread
00273         g_share_abort = TRUE;
00274 
00275         // stop any process spawned by shareThread
00276         pid_t pid = get_forkexec_child_pid();
00277         if (pid > 0)
00278         {
00279             kill(pid, SIGTERM);
00280         }
00281 
00282         // stop fileCopy that might be running on shareThread
00283         fileCopy_abort();
00284 
00285         return TRUE;
00286     }
00287     else
00288     {
00289         DL_ERRORPRINTF("share thread not running");
00290         return FALSE;
00291     }
00292 }

Here is the call graph for this function:

gboolean shareThread_wait ( int  timeout_sec  ) 

Definition at line 294 of file sharethread.c.

00295 {
00296     int max_ticks = 2 * timeout_sec;
00297 
00298     DL_LOGPRINTF("entry");
00299 
00300     if (g_share_thread)
00301     {
00302         // sorry don't like busy-wait, but g_thread_join has no timeout option
00303         while (g_share_thread  &&  --max_ticks >= 0)
00304         {
00305             g_usleep(500*1000L);
00306         }
00307         return TRUE;
00308     }
00309     else
00310     {
00311         DL_ERRORPRINTF("share thread not running");
00312         return FALSE;
00313     }
00314 }


Generated on Sun Dec 14 17:16:49 2008 by  doxygen 1.5.6