diff options
author | Christopher Faylor <me@cgf.cx> | 2001-09-28 07:01:22 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-09-28 07:01:22 +0000 |
commit | 8b51edbfa6c8f372f9ce68c7edad0046b71ce1fd (patch) | |
tree | c2bbc0c758f73a4e9b04520d32daaf1d6dfbd9d3 /winsup/cygwin/grp.cc | |
parent | 9c61aed684d15af5348870fcb271ca20dbc51e9b (diff) | |
download | cygnal-8b51edbfa6c8f372f9ce68c7edad0046b71ce1fd.tar.gz cygnal-8b51edbfa6c8f372f9ce68c7edad0046b71ce1fd.tar.bz2 cygnal-8b51edbfa6c8f372f9ce68c7edad0046b71ce1fd.zip |
* passwd.cc (read_etc_passwd): Don't bother with locking when
in cygwin initialization since there is only one thread.
* grp.cc (read_etc_group): Ditto.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r-- | winsup/cygwin/grp.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index 48a74e99c..e4a4afd6c 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -117,6 +117,14 @@ add_grp_line (const char *line) curr_lines++; } +class group_lock +{ + pthread_mutex_t mutex; + public: + group_lock (): mutex ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER) {} + void arm () {pthread_mutex_lock (&mutex); } +}; + /* 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 @@ -132,15 +140,13 @@ read_etc_group () strncpy (group_name, "Administrators", sizeof (group_name)); - static NO_COPY pthread_mutex_t etc_group_mutex = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER; - pthread_mutex_lock (&etc_group_mutex); + static NO_COPY group_lock here; + if (cygwin_finished_initializing) + here.arm (); /* if we got blocked by the mutex, then etc_group may have been processed */ if (group_state != uninitialized) - { - pthread_mutex_unlock(&etc_group_mutex); - return; - } + return; if (group_state != initializing) { @@ -193,7 +199,7 @@ read_etc_group () } } - pthread_mutex_unlock(&etc_group_mutex); + return; } extern "C" |