Changeset b8d1fb45af0974b7c419ec104d6936b3215118dc

Show
Ignore:
Timestamp:
08/26/11 14:27:18 (3 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1314368838 -0400
git-parent:

[7f6c1bc05282c6ef43cd04c1425b87d1dccd160c]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1314368838 -0400
Message:

use pshared locks as there is a rare race if the parent is logging in-flight during the fork.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/utils/noit_log.c

    r6c8c525 rb8d1fb4  
    666666} 
    667667 
     668static void 
     669noit_log_init_rwlock(noit_log_stream_t ls) { 
     670  pthread_rwlockattr_t attr; 
     671  pthread_rwlockattr_init(&attr); 
     672  pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); 
     673  pthread_rwlock_init(ls->lock, &attr); 
     674} 
     675 
    668676noit_log_stream_t 
    669677noit_log_stream_new_on_fd(const char *name, int fd, noit_hash_table *config) { 
     
    676684  ls->config = config; 
    677685  ls->lock = calloc(1, sizeof(*ls->lock)); 
    678   pthread_rwlock_init(ls->lock, NULL); 
     686  noit_log_init_rwlock(ls); 
    679687  /* This double strdup of ls->name is needed, look for the next one 
    680688   * for an explanation. 
     
    739747      goto freebail; 
    740748    ls->lock = calloc(1, sizeof(*ls->lock)); 
    741     pthread_rwlock_init(ls->lock, NULL); 
     749    noit_log_init_rwlock(ls); 
    742750  } 
    743751  /* This is for things that don't open on paths */