From bc025aada5956d6a1bd3e12526b24c80ceb6e7d9 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 31 Jul 2012 19:56:32 +0000 Subject: [PATCH] * path.cc (etc::dir_changed): Revert muto changes since function is called under lock condition anyway. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/path.cc | 48 +++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bf2f3365d..08d9d741c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2012-07-31 Corinna Vinschen + + * path.cc (etc::dir_changed): Revert muto changes since function is + called under lock condition anyway. + 2012-07-31 Corinna Vinschen * path.cc (etc::dir_changed): Change `io' to a static NO_COPY diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 859e95878..d1a881c39 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -4311,12 +4311,11 @@ etc::test_file_change (int n) bool etc::dir_changed (int n) { - static muto lock NO_COPY; - static HANDLE changed_h NO_COPY; /* io MUST be static because NtNotifyChangeDirectoryFile works asynchronously. It may write into io after the function has left, which may result in all sorts of stack corruption. */ static IO_STATUS_BLOCK io NO_COPY; + static HANDLE changed_h NO_COPY; if (!change_possible[n]) { @@ -4326,43 +4325,36 @@ etc::dir_changed (int n) { OBJECT_ATTRIBUTES attr; - lock.init ("etc_dir_changed_lock")->acquire (); - if (!changed_h) + path_conv dir ("/etc"); + status = NtOpenFile (&changed_h, SYNCHRONIZE | FILE_LIST_DIRECTORY, + dir.get_object_attr (attr, sec_none_nih), &io, + FILE_SHARE_VALID_FLAGS, FILE_DIRECTORY_FILE); + if (!NT_SUCCESS (status)) { - path_conv dir ("/etc"); - status = NtOpenFile (&changed_h, - SYNCHRONIZE | FILE_LIST_DIRECTORY, - dir.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_DIRECTORY_FILE); - if (!NT_SUCCESS (status)) - { #ifdef DEBUGGING - system_printf ("NtOpenFile (%S) failed, %p", - dir.get_nt_native_path (), status); + system_printf ("NtOpenFile (%S) failed, %p", + dir.get_nt_native_path (), status); #endif - changed_h = INVALID_HANDLE_VALUE; - } - else - { - status = NtNotifyChangeDirectoryFile (changed_h, NULL, NULL, + changed_h = INVALID_HANDLE_VALUE; + } + else + { + status = NtNotifyChangeDirectoryFile (changed_h, NULL, NULL, NULL, &io, NULL, 0, FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME, FALSE); - if (!NT_SUCCESS (status)) - { + if (!NT_SUCCESS (status)) + { #ifdef DEBUGGING - system_printf ("NtNotifyChangeDirectoryFile (1) failed, " - "%p", status); + system_printf ("NtNotifyChangeDirectoryFile (1) failed, %p", + status); #endif - NtClose (changed_h); - changed_h = INVALID_HANDLE_VALUE; - } + NtClose (changed_h); + changed_h = INVALID_HANDLE_VALUE; } - memset (change_possible, true, sizeof (change_possible)); } - lock.release (); + memset (change_possible, true, sizeof (change_possible)); } if (changed_h == INVALID_HANDLE_VALUE)