diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8d17d97af..4578b45d9 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +2003-01-21 Pierre Humblet + + * path.h (etc::change_possible): Revert the type to bool. + (etc::set_last_modified): Remove obsolete function. + * path.cc (etc::change_possible): Revert type to bool. + (etc::test_file_change): Do not test for negative values of + change_possible and do not set it to -res. + (etc::dir_changed): When the handle is NULL, call memset instead of + test_file_changed. When the handle is invalid, return true. + (etc::file_changed): Remove unneeded check for !fn[n]. + 2003-01-19 Christopher Faylor * pwdgrp.h (etc): Move to path.h. @@ -41,7 +52,6 @@ (etc::file_changed): Use test_file_change to detect if file needs to be updated. * path.h (etc): Move class here from pwdgrp.h. - * uinfo.cc: Move etc:: functions to path.cc. Move pwdgrp functions here. (pwdgrp::gets): Eliminate buf checks. Just check eptr and set lptr. @@ -78,7 +88,7 @@ * uinfo.cc (etc::dir_changed): Don't print a warning if can't open /etc, unless debugging. -2003-01-17 Pierre Humblet +2003-01-17 Pierre Humblet * grp.cc (read_etc_group): On NT, add a line for gid = -1. Change name "unknown" to "mkgroup". diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 835fa9838..9a2418fe3 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3756,7 +3756,7 @@ 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]; +bool etc::change_possible[MAX_ETC_FILES + 1]; const char *etc::fn[MAX_ETC_FILES + 1]; FILETIME etc::last_modified[MAX_ETC_FILES + 1]; @@ -3784,12 +3784,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 +3795,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,16 +3819,15 @@ 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 */ + change_possible[n] = true; else if (WaitForSingleObject (changed_h, 0) == WAIT_OBJECT_0) { (void) FindNextChangeNotification (changed_h); - memset (change_possible, 1, sizeof change_possible); + memset (change_possible, true, sizeof change_possible); } } @@ -3846,11 +3839,9 @@ bool etc::file_changed (int n) { bool res = false; - if (!fn[n]) + if (dir_changed (n) && test_file_change (n)) res = true; - else if (dir_changed (n) && test_file_change (n)) - res = true; - change_possible[n] = 0; + change_possible[n] = false; /* Change is no longer possible */ paranoid_printf ("fn[%d] %s res %d", n, fn[n], res); return res; } diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 7fab2044d..520b4907a 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -213,13 +213,12 @@ int path_prefix_p (const char *path1, const char *path2, int len1) __attribute__ class etc { static int curr_ix; - static signed char change_possible[MAX_ETC_FILES + 1]; + static bool change_possible[MAX_ETC_FILES + 1]; static const char *fn[MAX_ETC_FILES + 1]; static FILETIME last_modified[MAX_ETC_FILES + 1]; static bool dir_changed (int); static int init (int, const char *); static bool file_changed (int); - static void set_last_modified (int, FILETIME&); static bool test_file_change (int); friend class pwdgrp; }; diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h index 07a618ce1..566c40137 100644 --- a/winsup/cygwin/pwdgrp.h +++ b/winsup/cygwin/pwdgrp.h @@ -59,7 +59,6 @@ public: state = initializing; return state == initializing; } - void operator = (pwdgrp_state nstate) { state = nstate; } bool isuninitialized () const { return state == uninitialized; } bool load (const char *); diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 868fc7d96..2e10b47ed 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -452,7 +452,6 @@ pwdgrp::load (const char *posix_fname) if (buf) free (buf); buf = NULL; - fh = NULL; res = false; } else