Date: Tue, 9 Sep 2003 15:38:12 -0700 (PDT) From: David Xu <davidxu@FreeBSD.org> To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/lib/libpthread/thread thr_once.c thr_private.h Message-ID: <200309092238.h89McCbY019153@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200309092238.h89McCbY019153>