From 1795c53d86d904ea683b602260830c1caa1bca97 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 28 Sep 2001 07:23:18 +0000 Subject: [PATCH] * passwd.cc (read_etc_passwd): Bother with unlocking when not in cygwin initialization. * grp.cc (read_etc_group): Ditto. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/grp.cc | 5 +++++ winsup/cygwin/passwd.cc | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a2fdacc79..a9718b3e6 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +Fri Sep 28 03:23:04 2001 Christopher Faylor + + * passwd.cc (read_etc_passwd): Bother with unlocking when not + in cygwin initialization. + * grp.cc (read_etc_group): Ditto. + Fri Sep 28 02:57:03 2001 Christopher Faylor * passwd.cc (read_etc_passwd): Don't bother with locking when diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index e4a4afd6c..d9e7b02b4 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -123,6 +123,11 @@ class group_lock public: group_lock (): mutex ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER) {} void arm () {pthread_mutex_lock (&mutex); } + ~group_lock () + { + if (mutex != (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER) + pthread_mutex_unlock (&mutex); + } }; /* Cygwin internal */ diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index c86c07b6a..092473b12 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -115,6 +115,11 @@ class passwd_lock public: passwd_lock (): mutex ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER) {} void arm () {pthread_mutex_lock (&mutex); } + ~passwd_lock () + { + if (mutex != (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER) + pthread_mutex_unlock (&mutex); + } }; /* Read in /etc/passwd and save contents in the password cache.