summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/grp.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-02-17 04:59:55 +0000
committerChristopher Faylor <me@cgf.cx>2002-02-17 04:59:55 +0000
commit2bd22312df4fd5be14d8833a22ed7abbdcc35559 (patch)
tree2e976ef7c240c812b447017d75716d3ea1e3f7c5 /winsup/cygwin/grp.cc
parent9490dffa7b0c5497bb3a8f4eec9f0e460342adc1 (diff)
downloadcygnal-2bd22312df4fd5be14d8833a22ed7abbdcc35559.tar.gz
cygnal-2bd22312df4fd5be14d8833a22ed7abbdcc35559.tar.bz2
cygnal-2bd22312df4fd5be14d8833a22ed7abbdcc35559.zip
* 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.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc20
1 files changed, 12 insertions, 8 deletions
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)