From b739751db982170d8e10caa720e5c6a5a1918f37 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 7 Jun 2005 18:41:31 +0000 Subject: [PATCH] * cygthread.cc (cygthread::detach): Make error message a little more detailed. * fhandler.cc (fhandler_base::raw_read): Ditto for debug message. * dcrt0.cc (do_exit): Add some more synchronization tests. * fhandler_fifo.cc (fhandler_fifo::dup): Don't duplicate a nonexistent handle. Use derived return value rather than always retuning 0. * fhandler_netdrive.cc (fhandler_netdrive::exists): Wnet -> WNet. * winsup.h (exit_states): Add a couple of new exit states. --- winsup/cygwin/ChangeLog | 11 +++++++++++ winsup/cygwin/cygthread.cc | 2 +- winsup/cygwin/dcrt0.cc | 14 ++++++++++++-- winsup/cygwin/fhandler.cc | 2 +- winsup/cygwin/fhandler_fifo.cc | 9 +++++---- winsup/cygwin/fhandler_netdrive.cc | 2 +- winsup/cygwin/winsup.h | 2 ++ 7 files changed, 33 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 902b96f37..16a2307d5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +2005-06-07 Christopher Faylor + + * cygthread.cc (cygthread::detach): Make error message a little more + detailed. + * fhandler.cc (fhandler_base::raw_read): Ditto for debug message. + * dcrt0.cc (do_exit): Add some more synchronization tests. + * fhandler_fifo.cc (fhandler_fifo::dup): Don't duplicate a nonexistent + handle. Use derived return value rather than always retuning 0. + * fhandler_netdrive.cc (fhandler_netdrive::exists): Wnet -> WNet. + * winsup.h (exit_states): Add a couple of new exit states. + 2005-06-06 Corinna Vinschen * path.cc (symlink_info::check): If GetFileAttributes returns diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc index d032b0f07..af60abf2a 100644 --- a/winsup/cygwin/cygthread.cc +++ b/winsup/cygwin/cygthread.cc @@ -344,7 +344,7 @@ cygthread::detach (HANDLE sigwait) break; default: if (!exiting) - api_fatal ("WFMO failed waiting for cygthread '%s'", __name); + api_fatal ("WFMO failed waiting for cygthread '%s', %E", __name); break; } /* WAIT_OBJECT_0 means that the thread successfully read something, diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 457661000..ea0edbd0c 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1013,8 +1013,18 @@ do_exit (int status) #endif EnterCriticalSection (&exit_lock); - muto::set_exiting_thread (); - dll_global_dtors (); + + if (exit_state < ES_SET_MUTO) + { + exit_state = ES_SET_MUTO; + muto::set_exiting_thread (); + } + + if (exit_state < ES_GLOBAL_DTORS) + { + exit_state = ES_GLOBAL_DTORS; + dll_global_dtors (); + } if (exit_state < ES_EVENTS_TERMINATE) { diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 6c0eaec38..c5074a3fe 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -269,7 +269,7 @@ fhandler_base::raw_read (void *ptr, size_t& ulen) break; } default: - syscall_printf ("ReadFile %s failed, %E", get_name ()); + syscall_printf ("ReadFile %s(%p) failed, %E", get_name (), get_handle ()); __seterrno_from_win_error (errcode); bytes_read = (size_t) -1; break; diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index 4ff94bb4e..742b70c10 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -184,14 +184,15 @@ fhandler_fifo::dup (fhandler_base *child) if (!res) { fhandler_fifo *ff = (fhandler_fifo *) child; - if (!DuplicateHandle (hMainProc, get_output_handle (), hMainProc, - &ff->get_output_handle (), false, true, - DUPLICATE_SAME_ACCESS)) + if (get_output_handle () + && !DuplicateHandle (hMainProc, get_output_handle (), hMainProc, + &ff->get_output_handle (), false, true, + DUPLICATE_SAME_ACCESS)) { __seterrno (); child->close (); res = -1; } } - return 0; + return res; } diff --git a/winsup/cygwin/fhandler_netdrive.cc b/winsup/cygwin/fhandler_netdrive.cc index bad6b491c..8249673be 100644 --- a/winsup/cygwin/fhandler_netdrive.cc +++ b/winsup/cygwin/fhandler_netdrive.cc @@ -123,7 +123,7 @@ fhandler_netdrive::exists () nr.lpLocalName = NULL; nr.lpRemoteName = namebuf; DWORD ret = create_thread_and_wait (GET_RESOURCE_INFO, &nr, NULL, 0, - "WnetGetResourceInformation"); + "WNetGetResourceInformation"); if (ret != ERROR_MORE_DATA && ret != NO_ERROR) return 0; return 1; diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 9d7cc96a5..2cc4c0ce0 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -187,6 +187,8 @@ extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *); enum exit_states { ES_NOT_EXITING = 0, + ES_SET_MUTO, + ES_GLOBAL_DTORS, ES_EVENTS_TERMINATE, ES_THREADTERM, ES_SIGNAL,