cvs commit: src/lib/libpthread/thread thr_once.c thr_private.h

From: David Xu <davidxu_at_FreeBSD.org>
Date: Tue, 9 Sep 2003 15:38:12 -0700 (PDT)
davidxu     2003/09/09 15:38:12 PDT

  FreeBSD src repository

  Modified files:
    lib/libpthread/thread thr_once.c thr_private.h 
  Log:
  Original pthread_once code has memory leak if pthread_once_t is used in
  a shared library or any other dyanmic allocated data block, once
  pthread_once_t is initialized, a mutex is allocated, if we unload the
  shared library or free those data block, then there is no way to deallocate
  the mutex, result is memory leak.
  To fix this problem, we don't use mutex field in pthread_once_t, instead,
  we use its state field and an internal mutex and conditional variable in
  libkse to do any synchronization, we introduce a third state IN_PROGRESS to
  wait if another thread is already in invoking init_routine().
  Also while I am here, make pthread_once() conformed to pthread cancellation
  point specification.
  
  Reviewed by: deischen
  
  Revision  Changes    Path
  1.9       +50 -9     src/lib/libpthread/thread/thr_once.c
  1.101     +2 -0      src/lib/libpthread/thread/thr_private.h
Received on Tue Sep 09 2003 - 15:38:15 UTC