IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15030


Ignore:
Timestamp:
Sep 25, 2007, 6:10:12 PM (19 years ago)
Author:
eugene
Message:

lock on init to avoid competition on init

File:
1 edited

Legend:

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

    r10667 r15030  
    3030static int Nstreams = 0;
    3131
     32static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
     33
    3234void gprintInit () {
    3335
     
    3638
    3739  /* need to use a mutex to prevent two threads from initing simultaneously */
     40  pthread_mutex_lock (&mutex);
     41
    3842  if (streams == NULL) {
    3943    Nstreams = 2;
     
    6670  streams[N].mode = GP_FILE;
    6771  streams[N].thread = id;
     72
     73  pthread_mutex_unlock (&mutex);
    6874}
    6975
Note: See TracChangeset for help on using the changeset viewer.