* sigproc.cc (cygWFMO): Don't assume that cancellable event is always

available.
* fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::waitforspace): Use cygWFMO
instead of WaitForMultipleObjects.
(fhandler_dev_dsp::Audio_in::waitfordata): Ditto.
* fhandler_fifo.cc (fhandler_fifo::wait): Ditto.
* fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
(fhandler_serial::raw_write): Ditto.
* fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
* select.cc (cygwin_select): Ditto for degenerate case.
This commit is contained in:
Christopher Faylor 2011-12-04 18:32:00 +00:00
parent 4510afa90d
commit 79e59d522a
7 changed files with 26 additions and 31 deletions

View File

@ -1,3 +1,16 @@
2011-12-04 Christopher Faylor <me.cygwin2011@cgf.cx>
* sigproc.cc (cygWFMO): Don't assume that cancellable event is always
available.
* fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::waitforspace): Use
cygWFMO instead of WaitForMultipleObjects.
(fhandler_dev_dsp::Audio_in::waitfordata): Ditto.
* fhandler_fifo.cc (fhandler_fifo::wait): Ditto.
* fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
(fhandler_serial::raw_write): Ditto.
* fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
* select.cc (cygwin_select): Ditto for degenerate case.
2011-12-04 Christopher Faylor <me.cygwin2011@cgf.cx>
* sigproc.h (cygWFMO): Move inside "INSIDE_CYGWIN" #ifdef.

View File

@ -540,10 +540,8 @@ fhandler_dev_dsp::Audio_out::waitforspace ()
set_errno (EAGAIN);
return false;
}
HANDLE w4[2] = { signal_arrived, pthread::get_cancel_event () };
DWORD cnt = w4[1] ? 2 : 1;
debug_printf ("100ms");
switch (WaitForMultipleObjects (cnt, w4, FALSE, 100))
switch (cygWFMO (0, 100))
{
case WAIT_OBJECT_0:
if (!_my_tls.call_signal_handler ())
@ -920,10 +918,8 @@ fhandler_dev_dsp::Audio_in::waitfordata ()
set_errno (EAGAIN);
return false;
}
HANDLE w4[2] = { signal_arrived, pthread::get_cancel_event () };
DWORD cnt = w4[1] ? 2 : 1;
debug_printf ("100ms");
switch (WaitForMultipleObjects (cnt, w4, FALSE, 100))
switch (cygWFMO (0, 100))
{
case WAIT_OBJECT_0:
if (!_my_tls.call_signal_handler ())

View File

@ -210,15 +210,13 @@ fhandler_fifo::wait (HANDLE h)
else
what = "overlapped event";
#endif
HANDLE w4[3] = {h, signal_arrived, pthread::get_cancel_event ()};
/* Set the wait to zero for non-blocking I/O-related events. */
DWORD wait = ((h == read_ready || h == write_ready)
&& get_flags () & O_NONBLOCK) ? 0 : INFINITE;
debug_only_printf ("waiting for %s", what);
/* Wait for the event. Set errno, as appropriate if something goes wrong. */
switch (WaitForMultipleObjects (3, w4, false, wait))
switch (cygWFMO (1, wait))
{
case WAIT_OBJECT_0:
debug_only_printf ("successfully waited for %s", what);

View File

@ -94,12 +94,9 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
}
else
{
HANDLE w4[3] = { io_status.hEvent, signal_arrived,
pthread::get_cancel_event () };
DWORD cnt = w4[2] ? 3 : 2;
overlapped_armed = 1;
restart:
switch (WaitForMultipleObjects (cnt, w4, FALSE, INFINITE))
switch (cygWFMO (1, INFINITE, io_status.hEvent))
{
case WAIT_OBJECT_0:
if (!GetOverlappedResult (get_handle (), &io_status, &n,
@ -205,11 +202,8 @@ fhandler_serial::raw_write (const void *ptr, size_t len)
if (!is_nonblocking ())
{
HANDLE w4[3] = { write_status.hEvent, signal_arrived,
pthread::get_cancel_event () };
DWORD cnt = w4[2] ? 3 : 2;
restart:
switch (WaitForMultipleObjects (cnt, w4, FALSE, INFINITE))
switch (cygWFMO (1, INFINITE, write_status.hEvent))
{
case WAIT_OBJECT_0:
break;

View File

@ -702,10 +702,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
while (len)
{
HANDLE w4[3] = { input_available_event, signal_arrived,
pthread::get_cancel_event () };
DWORD cnt = w4[2] ? 3 : 2;
switch (WaitForMultipleObjects (cnt, w4, FALSE, time_to_wait))
switch (cygWFMO (1, time_to_wait, input_available_event))
{
case WAIT_OBJECT_0:
break;
@ -741,8 +738,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
}
/* Now that we know that input is available we have to grab the
input mutex. */
w4[0] = input_mutex;
switch (WaitForMultipleObjects (cnt, w4, FALSE, 1000))
switch (cygWFMO (1, 1000, input_mutex))
{
case WAIT_OBJECT_0:
case WAIT_ABANDONED_0:

View File

@ -133,10 +133,7 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
/* Degenerate case. No fds to wait for. Just wait. */
if (sel.start.next == NULL)
{
HANDLE w4[2] = { signal_arrived, pthread::get_cancel_event () };
DWORD cnt = w4[1] ? 2 : 1;
switch (WaitForMultipleObjects (cnt, w4, FALSE, ms))
switch (cygWFMO (0, ms))
{
case WAIT_OBJECT_0:
select_printf ("signal received");

View File

@ -88,11 +88,12 @@ DWORD cygWFMO (DWORD n, DWORD howlong, ...)
va_start (ap, howlong);
HANDLE w4[n + 2];
va_start (ap, howlong);
unsigned i;
for (i = 0; i < n; i++)
for (unsigned i = 0; i < n; i++)
w4[i] = va_arg (ap, HANDLE);
w4[i++] = signal_arrived;
w4[i++] = pthread::get_cancel_event ();
w4[n++] = signal_arrived;
w4[n++] = pthread::get_cancel_event ();
if (!w4[n - 1])
n--;
return WaitForMultipleObjects (n, w4, FALSE, howlong);
}
#endif