From 2bd22312df4fd5be14d8833a22ed7abbdcc35559 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 17 Feb 2002 04:59:55 +0000 Subject: * times.cc (hires::prime): Restore thread priority on failure condition. * uinfo.cc (uinfo_init): Use more robust method for determining if process was invoked from a non-cygwin process. * sync.h (muto::init): Eliminate "inheritance" parameter. (new_muto): Reflect removal of parameter. * sync.cc (muto::init): Ditto. * cygheap.cc (cygheap_init): Ditto. * debug.cc (threadname_init): Ditto. * exceptions.cc (events_init): Ditto. * malloc.cc (malloc_init): Ditto. * path.cc (cwdstuff::init): Ditto. * sigproc.cc (sigproc_init): Ditto. * grp.cc (group_lock): Use different method for locking with static member. (read_etc_group): REALLY ensure that read lock mutex is released. * passwd.cc (passwd_lock): Use different method for locking with static member. (read_etc_passwd): REALLY ensure that read lock mutex is released. * shared.cc (sec_user): Correct reversed inheritance test. --- winsup/cygwin/grp.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'winsup/cygwin/grp.cc') diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index c5804b70b..d88deb994 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -31,7 +31,7 @@ details. */ /* Read /etc/group only once for better performance. This is done on the first call that needs information from it. */ -static NO_COPY const char *etc_group = "/etc/group"; +static const char *etc_group NO_COPY = "/etc/group"; static struct __group16 *group_buf; /* group contents in memory */ static int curr_lines; static int max_lines; @@ -119,17 +119,23 @@ add_grp_line (const char *line) class group_lock { - pthread_mutex_t mutex; + bool armed; + static NO_COPY pthread_mutex_t mutex; public: - group_lock (): mutex ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER) {} - void arm () {pthread_mutex_lock (&mutex); } + group_lock (bool doit) + { + if (armed = doit) + pthread_mutex_lock (&mutex); + } ~group_lock () { - if (mutex != (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER) + if (armed) pthread_mutex_unlock (&mutex); } }; +pthread_mutex_t NO_COPY group_lock::mutex = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER; + /* Cygwin internal */ /* Read in /etc/group and save contents in the group cache */ /* This sets group_in_memory_p to 1 so functions in this file can @@ -145,9 +151,7 @@ read_etc_group () strncpy (group_name, "Administrators", sizeof (group_name)); - static NO_COPY group_lock here = group_lock(); - if (cygwin_finished_initializing) - here.arm (); + group_lock here (cygwin_finished_initializing); /* if we got blocked by the mutex, then etc_group may have been processed */ if (group_state != uninitialized) -- cgit v1.2.3