Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-07-22 02:58:20 +0400
committerChristopher Faylor <me@cgf.cx>2012-07-22 02:58:20 +0400
commit962f9a2ccc6cd7f24a2d89d68bd8b59d43f8ac8a (patch)
treec82af5083b39d153b67207bbc4c6f11f281c405c /winsup/cygwin/fhandler_windows.cc
parentb8a84b73d79d1a5ae2a5a4d6c226f84b9543908f (diff)
* DevNotes: Add entry cgf-000013.
* cygserver_ipc.h (ipc_set_proc_info): Use _cygtls::ipc_set_proc_info to set per-thread signal arrived value. * cygthread.cc (cygthread::detach): Use per-thread signal_arrived via set_thread_waiting. * fork.cc (_cygtls::fixup_after_fork): Clear signal_arrived. (_cygtls::remove): Close any signal_arrived handle when thread exists. (_cygtls::find_tls): Remove unneeded function. * cygtls.h: Update copyright. (class _cygtls): Reorganize to help avoid rebuilding newlib when structure changes. (_cygtls::event): Delete. (_cygtls::threadkill): Ditto. (_cygtls::signal_waiting): Declare new bool. (_cygtls::find_tls): Delete declaration. (_cygtls::set_threadkill): Ditto. (_cygtls::reset_threadkill): Ditto. (_cygtls::set_signal_arrived): Declare new function. (class set_thread_waiting): Declare new class. * cygwait.cc (cw_nowait_storage): Define. (cygwait): Set per-thread signal_arrived via set_thread_waiting. Don't special-case _main_tls. * cygwait.h (cw_nowait): Define. (cw_infinite): Ditto. (cygwait): Redefine pathological wait-only case. * dcrt0.cc (dll_crt0_0): Remove call to now-defunct events_init(). (dll_crt0_1): Remove call to now-defunct create_signal_arrived(). * exceptions.cc: Reflect set_signal_mask() argument reordering throughout. Remove signal mask synchronization throughout. (events_init): Delete definition. (mask_sync): Delete now-unneeded mask synchronization. (set_signal_mask): Reverse order of arguments to "standard" to, from layout. Rename "newmask" argument to "setmask". Remove debugging. (sig_handle_tty_stop): Use cancelable_wait rather than WFMO. (_cygtls::interrupt_setup): Don't treat "threadkill" events specially. Conditionally set signal_arrived depending on whether the thread has created it or not. (sigpacket::process): Reorganize to reflect thread-specific sending of signals which is more in line with the way it was actually supposed to work. * fhandler_socket.cc (get_inet_addr): Use cancelable_wait rather than IsEventSignalled to avoid potential race. (fhandler_socket::wait_for_events): Set signal_arrived event using set_thread_waiting(). (fhandler_socket::close): Use cygwait for the case of just waiting 10 ms for a signal. * fhandler_tape.cc (fhandler_dev_tape::_lock): Use cancelable_wait rather than WFMO. Redo switch/case tests accordingly. * fhandler_termios.cc (fhandler_termios::bg_check): Use cygwait for case of just waiting 0 ms for a potential signal. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Use cancelable_wait rather than WFSO. * fhandler_windows.cc (fhandler_windows::read): Set per-thread signal_arrived via set_thread_waiting(). * flock.cc (lf_setlock): Ditto. * select.cc (pselect): Ditto. Set per-thread signal_arrived using set_thread_waiting(). * gendef: Don't special case handling of _cygtls::sig for threads. * gentls_offsets: Use #pragma once in tlsoffsets.h. * ntdll.h: Use #pragma once. * poll.cc: Reflect set_signal_mask() argument reordering. * posix_ipc.cc (ipc_mutex_lock): Use cancelable_wait rather than WFMO. (ipc_cond_timedwait): Set perl-thread signal arrived using set_thread_waiting(). * security.h: Use #pragma once. * signal.cc (abort): Reflect set_signal_mask() argument reordering. (clock_nanosleep): Ditto. Change call to cancelable_wait to properly specify handling of cancel and interrupt. (sigwaitinfo): Remove handling of per-thread event in favor of per-thread signal_arrived. Use cancelable_wait rather than WFSO. * sigproc.cc (signal_arrived): Delete definition. (create_signal_arrived): Ditto. * sigproc.h (signal_arrived): Delete declaration. (set_signal_mask): Avoid defining as a "C" function. Don't conditionally declare. (create_signal_arrived): Delete declaration. * syscalls.cc (rename): Use cygwait() rather than WFSO. * thread.h (fast_mutex::lock): Use cw_infinite rather than LARGE_NULL. * wait.cc (wait4): Ditto. * thread.cc (pthread_mutex::lock): Ditto. (pthread::join): Ditto. (semaphore::_wait): Ditto. (pthread_kill): Remove set_threadkill() accommodation. * tlsoffsets.h: Regenerate.
Diffstat (limited to 'winsup/cygwin/fhandler_windows.cc')
-rw-r--r--winsup/cygwin/fhandler_windows.cc62
1 files changed, 33 insertions, 29 deletions
diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc
index c89d98e16..11fb6c0a0 100644
--- a/winsup/cygwin/fhandler_windows.cc
+++ b/winsup/cygwin/fhandler_windows.cc
@@ -96,43 +96,47 @@ fhandler_windows::read (void *buf, size_t& len)
return;
}
- HANDLE w4[3] = { get_handle (), signal_arrived, NULL };
+ HANDLE w4[3] = { get_handle (), };
+ set_thread_waiting here (w4[1]);
DWORD cnt = 2;
if ((w4[cnt] = pthread::get_cancel_event ()) != NULL)
++cnt;
-restart:
- switch (MsgWaitForMultipleObjectsEx (cnt, w4,
- is_nonblocking () ? 0 : INFINITE,
- QS_ALLINPUT | QS_ALLPOSTMESSAGE,
- MWMO_INPUTAVAILABLE))
+ for (;;)
{
- case WAIT_OBJECT_0:
- if (!PeekMessageW (ptr, hWnd_, 0, 0, PM_REMOVE))
+ switch (MsgWaitForMultipleObjectsEx (cnt, w4,
+ is_nonblocking () ? 0 : INFINITE,
+ QS_ALLINPUT | QS_ALLPOSTMESSAGE,
+ MWMO_INPUTAVAILABLE))
{
+ case WAIT_OBJECT_0:
+ if (!PeekMessageW (ptr, hWnd_, 0, 0, PM_REMOVE))
+ {
+ len = (size_t) -1;
+ __seterrno ();
+ }
+ else if (ptr->message == WM_QUIT)
+ len = 0;
+ else
+ len = sizeof (MSG);
+ break;
+ case WAIT_OBJECT_0 + 1:
+ if (_my_tls.call_signal_handler ())
+ continue;
+ len = (size_t) -1;
+ set_errno (EINTR);
+ break;
+ case WAIT_OBJECT_0 + 2:
+ pthread::static_cancel_self ();
+ break;
+ case WAIT_TIMEOUT:
+ len = (size_t) -1;
+ set_errno (EAGAIN);
+ break;
+ default:
len = (size_t) -1;
__seterrno ();
+ break;
}
- else if (ptr->message == WM_QUIT)
- len = 0;
- else
- len = sizeof (MSG);
- break;
- case WAIT_OBJECT_0 + 1:
- if (_my_tls.call_signal_handler ())
- goto restart;
- len = (size_t) -1;
- set_errno (EINTR);
- break;
- case WAIT_OBJECT_0 + 2:
- pthread::static_cancel_self ();
- break;
- case WAIT_TIMEOUT:
- len = (size_t) -1;
- set_errno (EAGAIN);
- break;
- default:
- len = (size_t) -1;
- __seterrno ();
break;
}
}