diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a4c4424cc..20a009c1a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2011-05-02 Christopher Faylor + + * dll_init.cc (dll_list::alloc): Reset 'p' in forked process. + + * select.cc (select_stuff::wait): Move cleanup() closer to WFMO to + minimize unavoidable (?) race. + 2011-05-02 Corinna Vinschen * fhandler_serial.cc (fhandler_serial::raw_read): Add restartability diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index f457b2766..85f3bae3f 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -126,6 +126,7 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type) { if (!in_forkee) d->count++; /* Yes. Bump the usage count. */ + d->p = p; } else { diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index 79ab59c2c..e224211b4 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -131,7 +131,7 @@ fs_info_cache::genhash (PFILE_FS_VOLUME_INFORMATION pffvi) { uint32_t hash = 0; const uint16_t *p = (const uint16_t *) pffvi; - const uint16_t *end = (const uint16_t *) + const uint16_t *end = (const uint16_t *) ((const uint8_t *) p + sizeof *pffvi + pffvi->VolumeLabelLength - sizeof (WCHAR)); pffvi->__dummy = 0; /* This member can have random values! */ @@ -378,7 +378,7 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol) any remote CIFS. */ has_buggy_fileid_dirinfo (is_cifs () || is_unixfs ()); /* NWFS is known to have a broken FileBasicInformation info class. - It can't be used to fetch information, only to set information. + It can't be used to fetch information, only to set information. Therefore, for NWFS we have to fallback to the FileNetworkOpenInformation info class. Unfortunately we can't use FileNetworkOpenInformation all the time since that fails on @@ -1055,7 +1055,7 @@ fstab_read_flags (char **options, unsigned &flags, bool external) *p++ = '\0'; else p = strchr (*options, '\0'); - + key.name = *options; opt *o = (opt *) bsearch (&key, oopts, sizeof oopts / sizeof (opt), diff --git a/winsup/cygwin/pseudo-reloc.cc b/winsup/cygwin/pseudo-reloc.cc index 290c1a838..beef50c31 100644 --- a/winsup/cygwin/pseudo-reloc.cc +++ b/winsup/cygwin/pseudo-reloc.cc @@ -1,9 +1,9 @@ -/* pseudo-reloc.c +/* pseudo-reloc.cc Contributed by Egor Duda Modified by addition of runtime_pseudo_reloc version 2 by Kai Tietz - + THIS SOFTWARE IS NOT COPYRIGHTED This source code is offered for use in the public domain. You may diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 57eb2946d..6c093a06d 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -146,7 +146,6 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, else if ((timeout = sel.wait (r, w, e, ms) < 0)) return -1; /* some kind of error */ - sel.cleanup (); copyfd_set (readfds, r, maxfds); copyfd_set (writefds, w, maxfds); copyfd_set (exceptfds, e, maxfds); @@ -290,7 +289,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, wait_ret = WaitForMultipleObjects (m, w4, FALSE, ms); else /* Using MWMO_INPUTAVAILABLE is the officially supported solution for - the problem that the call to PeekMessage disarms the queue state + the problem that the call to PeekMessage disarms the queue state so that a subsequent MWFMO hangs, even if there are still messages in the queue. */ wait_ret = @@ -301,15 +300,18 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, switch (wait_ret) { case WAIT_OBJECT_0: + cleanup (); select_printf ("signal received"); set_sig_errno (EINTR); return -1; case WAIT_FAILED: + cleanup (); system_printf ("WaitForMultipleObjects failed"); s = &start; s->set_select_errno (); return -1; case WAIT_TIMEOUT: + cleanup (); select_printf ("timed out"); res = 1; goto out; @@ -325,6 +327,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, while ((s = s->next)) if (s->saw_error ()) { + cleanup (); set_errno (s->saw_error ()); return -1; /* Somebody detected an error */ } @@ -334,7 +337,10 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, select_printf ("gotone %d", gotone); if (gotone) - goto out; + { + cleanup (); + goto out; + } if (ms == INFINITE) { @@ -346,6 +352,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, LONGLONG now = gtod.msecs (); if (now > (start_time + ms)) { + cleanup (); select_printf ("timed out after verification"); goto out; } diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 53ef7438e..60173cda6 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -50,12 +50,12 @@ static LONG installation_root_inited __attribute__((section (".cygwin_dll_common used when generating shared object names. Thus, different Cygwin installations generate different object names and so are isolated from each other. - + Having this information, the installation key together with the installation root path is written to the registry. The idea is that cygcheck can print the paths into which the Cygwin DLL has been installed for debugging purposes. - + Last but not least, the new cygwin properties datastrcuture is checked for the "disabled_key" value, which is used to determine whether the installation key is actually added to all object names or not. This is @@ -373,7 +373,7 @@ shared_info::init_obcaseinsensitive () { NTSTATUS status; DWORD def_obcaseinsensitive = 1; - + obcaseinsensitive = def_obcaseinsensitive; RTL_QUERY_REGISTRY_TABLE tab[2] = { { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_NOSTRING, diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index 8b13b20d8..5ee434e89 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -600,7 +600,7 @@ sys_cp_mbstowcs (mbtowc_p f_mbtowc, const char *charset, wchar_t *dst, Invalid bytes in a multibyte secuence are converted to the private use area which is already used to store ASCII - chars invalid in Windows filenames. This technque allows + chars invalid in Windows filenames. This technque allows to store them in a symmetric way. */ bytes = 1; if (dst) diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index 9f94d2dd4..c28c0bab6 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -513,7 +513,7 @@ hires_ms::timeGetTime_ns () of the value returned by timeGetTime, only relative accuracy, we can skip this step. However, if we ever find out that we need absolute accuracy, here's how it works in it's full beauty: - + - At process startup, winmm initializes two calibration values: DWORD tick_count_start;