diff options
author | Christopher Faylor <me@cgf.cx> | 2003-01-24 06:53:46 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-01-24 06:53:46 +0300 |
commit | ac4133746eeaad61b2bb2f71bd8861615b052427 (patch) | |
tree | 40d48ebf8a73cbd5ec8a206ab0a953033942d303 /winsup/cygwin/pwdgrp.h | |
parent | 09a88426740b765a99759d29da0e2a5f98c7281b (diff) |
* pwdrp.h (pwdgrp::refresh): Lock entire test prior to reading.
* grp.cc (pwdgrp::parse_group): Eliminate arg and use class member instead.
Use next_str and next_int to parse arguments.
* passwd.cc (pwdgrp::parse_passwd): Ditto.
(grab_string): Eliminate.
(grab_int): Ditto.
* pwdgrp.h (pwdgrp::parse): Eliminate input arg.
(pwdgrp::parse_passwd): Reflect above change.
(pwdgrp::parse_group): Reflect above change.
(pwdgrp::next_str): New function.
(pwdgrp::next_int): Ditto.
(pwdgrp::gets): Eliminate.
* uinfo.cc (pwdgrp::next_str): New function.
(pwdgrp::next_int): Ditto.
(pwdgrp::add_line): Subsume gets.
(pwdgrp::gets): Eliminate.
(pwdgrp::load): Just call add_line to parse input buffer.
Diffstat (limited to 'winsup/cygwin/pwdgrp.h')
-rw-r--r-- | winsup/cygwin/pwdgrp.h | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h index eb0a974d1..ede380866 100644 --- a/winsup/cygwin/pwdgrp.h +++ b/winsup/cygwin/pwdgrp.h @@ -21,6 +21,7 @@ extern struct __group32 *internal_getgrnam (const char *, bool = FALSE); extern struct __group32 *internal_getgrent (int); int internal_getgroups (int, __gid32_t *, cygsid * = NULL); +#include "sync.h" class pwdgrp { unsigned pwdgrp_buf_elem_size; @@ -31,51 +32,48 @@ class pwdgrp void **pwdgrp_buf; }; void (pwdgrp::*read) (); - bool (pwdgrp::*parse) (char *); + bool (pwdgrp::*parse) (); int etc_ix; path_conv pc; - char *buf; + char *buf, *lptr; int max_lines; bool initialized; - CRITICAL_SECTION lock; + muto *pglock; - char *gets (char*&); + bool parse_passwd (); + bool parse_group (); + void read_passwd (); + void read_group (); + char *add_line (char *); + char *pwdgrp::next_str (char = 0); + int pwdgrp::next_int (char = 0); public: int curr_lines; - bool parse_passwd (char *); - bool parse_group (char *); - void read_passwd (); - void read_group (); - - void add_line (char *); + bool load (const char *); void refresh (bool check = true) { - if (initialized && check && etc::file_changed (etc_ix)) - initialized = false; - if (!initialized) - { - EnterCriticalSection (&lock); - if (!initialized) - (this->*read) (); - LeaveCriticalSection (&lock); - } + if (!check && initialized) + return; + pglock->acquire (); + if (!initialized || (check && etc::file_changed (etc_ix))) + (this->*read) (); + pglock->release (); } - bool load (const char *); pwdgrp (passwd *&pbuf) : pwdgrp_buf_elem_size (sizeof (*pbuf)), passwd_buf (&pbuf) { read = &pwdgrp::read_passwd; parse = &pwdgrp::parse_passwd; - InitializeCriticalSection (&lock); + new_muto (pglock); } pwdgrp (__group32 *&gbuf) : pwdgrp_buf_elem_size (sizeof (*gbuf)), group_buf (&gbuf) { read = &pwdgrp::read_group; parse = &pwdgrp::parse_group; - InitializeCriticalSection (&lock); + new_muto (pglock); } }; |