IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17069


Ignore:
Timestamp:
Mar 19, 2008, 2:49:00 PM (18 years ago)
Author:
eugene
Message:

block against other threads setting the file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/gprint.c

    r16902 r17069  
    152152}
    153153
     154static pthread_mutex_t set_file_mutex = PTHREAD_MUTEX_INITIALIZER;
     155
    154156void gprintSetFileAllThreads (gpDest dest, char *filename) {
    155157
    156158  int i;
     159
     160  /* need to use a mutex to prevent two threads from initing simultaneously */
     161  pthread_mutex_lock (&set_file_mutex);
    157162
    158163  for (i = 0; i < Nstreams; i++) {
     
    160165    gprintSetFile (&streams[i], dest, filename);
    161166  }
     167
     168  pthread_mutex_unlock (&set_file_mutex);
    162169  return;
    163170}
     
    168175  stream = gprintGetStream (dest);
    169176
     177  /* need to use a mutex to prevent two threads from initing simultaneously */
     178  pthread_mutex_lock (&set_file_mutex);
     179
    170180  gprintSetFile (stream, dest, filename);
     181
     182  pthread_mutex_unlock (&set_file_mutex);
    171183  return;
    172184}
Note: See TracChangeset for help on using the changeset viewer.