Index: pwdgrp.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/pwdgrp.h,v retrieving revision 1.12 diff -u -p -r1.12 pwdgrp.h --- pwdgrp.h 20 Jan 2003 02:57:54 -0000 1.12 +++ pwdgrp.h 21 Jan 2003 00:09:57 -0000 @@ -53,11 +53,10 @@ public: void add_line (char *); bool isinitializing () { - if (state <= initializing) + if (state == loaded + && etc::file_changed (pwd_ix)) state = initializing; - else if (etc::file_changed (pwd_ix)) - state = initializing; - return state == initializing; + return state <= initializing; } void operator = (pwdgrp_state nstate) { state = nstate; } bool isuninitialized () const { return state == uninitialized; } Index: uinfo.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/uinfo.cc,v retrieving revision 1.101 diff -u -p -r1.101 uinfo.cc --- uinfo.cc 20 Jan 2003 02:57:54 -0000 1.101 +++ uinfo.cc 21 Jan 2003 00:10:08 -0000 @@ -429,7 +429,8 @@ pwdgrp::load (const char *posix_fname) buf = NULL; pc.check (posix_fname); - pwd_ix = etc::init (pwd_ix, pc); + if (state == uninitialized) + pwd_ix = etc::init (pc); paranoid_printf ("%s", posix_fname); Index: path.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/path.h,v retrieving revision 1.49 diff -u -p -r1.49 path.h --- path.h 20 Jan 2003 02:57:54 -0000 1.49 +++ path.h 21 Jan 2003 00:10:16 -0000 @@ -213,13 +213,12 @@ int path_prefix_p (const char *path1, co class etc { static int curr_ix; - static signed char change_possible[MAX_ETC_FILES + 1]; - static const char *fn[MAX_ETC_FILES + 1]; - static FILETIME last_modified[MAX_ETC_FILES + 1]; + static bool change_possible[MAX_ETC_FILES]; + static const char *fn[MAX_ETC_FILES]; + static FILETIME last_modified[MAX_ETC_FILES]; static bool dir_changed (int); - static int init (int, const char *); + static int init (const char *); static bool file_changed (int); - static void set_last_modified (int, FILETIME&); static bool test_file_change (int); friend class pwdgrp; }; Index: path.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/path.cc,v retrieving revision 1.240 diff -u -p -r1.240 path.cc --- path.cc 20 Jan 2003 02:57:54 -0000 1.240 +++ path.cc 21 Jan 2003 00:10:31 -0000 @@ -3756,25 +3756,23 @@ out: int etc::curr_ix = 0; /* Note that the first elements of the below arrays are unused */ -signed char etc::change_possible[MAX_ETC_FILES + 1]; -const char *etc::fn[MAX_ETC_FILES + 1]; -FILETIME etc::last_modified[MAX_ETC_FILES + 1]; +bool etc::change_possible[MAX_ETC_FILES]; +const char *etc::fn[MAX_ETC_FILES]; +FILETIME etc::last_modified[MAX_ETC_FILES]; int -etc::init (int n, const char *etc_fn) +etc::init (const char *etc_fn) { - if (n > 0) - /* ok */; - else if (++curr_ix <= MAX_ETC_FILES) - n = curr_ix; + if (curr_ix < MAX_ETC_FILES) + { + fn[curr_ix] = etc_fn; + (void) file_changed (curr_ix); + } else api_fatal ("internal error"); - fn[n] = etc_fn; - change_possible[n] = false; - (void) test_file_change (n); - paranoid_printf ("fn[%d] %s, curr_ix %d", n, fn[n], curr_ix); - return n; + paranoid_printf ("fn[%d] %s, curr_ix %d", curr_ix, fn[curr_ix], curr_ix); + return curr_ix++; } bool @@ -3784,12 +3782,7 @@ etc::test_file_change (int n) WIN32_FIND_DATA data; bool res; - if (change_possible[n] < 0) - { - res = true; - paranoid_printf ("fn[%d] %s, already marked changed", n, fn[n]); - } - else if ((h = FindFirstFile (fn[n], &data)) == INVALID_HANDLE_VALUE) + if ((h = FindFirstFile (fn[n], &data)) == INVALID_HANDLE_VALUE) { res = true; memset (last_modified + n, 0, sizeof (last_modified[n])); @@ -3800,7 +3793,6 @@ etc::test_file_change (int n) FindClose (h); res = CompareFileTime (&data.ftLastWriteTime, last_modified + n) > 0; last_modified[n] = data.ftLastWriteTime; - change_possible[n] = -res; debug_printf ("FindFirstFile succeeded"); } @@ -3825,12 +3817,11 @@ etc::dir_changed (int n) system_printf ("Can't open /etc for checking, %E", (char *) pwd, changed_h); #endif - for (int i = 1; i <= curr_ix; i++) - (void) test_file_change (i); + memset (change_possible, true, sizeof change_possible); } if (changed_h == INVALID_HANDLE_VALUE) - (void) test_file_change (n); /* semi-brute-force way */ + return true; else if (WaitForSingleObject (changed_h, 0) == WAIT_OBJECT_0) { (void) FindNextChangeNotification (changed_h);