From owner-cvs-src@FreeBSD.ORG Tue Sep 9 15:38:15 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 05F2316A4BF; Tue, 9 Sep 2003 15:38:15 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8887343FE3; Tue, 9 Sep 2003 15:38:13 -0700 (PDT) (envelope-from davidxu@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h89McD0U019154; Tue, 9 Sep 2003 15:38:13 -0700 (PDT) (envelope-from davidxu@repoman.freebsd.org) Received: (from davidxu@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h89McCbY019153; Tue, 9 Sep 2003 15:38:12 -0700 (PDT) Message-Id: <200309092238.h89McCbY019153@repoman.freebsd.org> From: David Xu Date: Tue, 9 Sep 2003 15:38:12 -0700 (PDT) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/lib/libpthread/thread thr_once.c thr_private.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Sep 2003 22:38:15 -0000 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