From 7ec66a2c28257d1dc25b08f457b9030bf4528d6f Mon Sep 17 00:00:00 2001 From: Thomas Pfaff Date: Tue, 14 Jan 2003 20:05:49 +0000 Subject: [PATCH] Apply sleep_cancel patch --- winsup/cygwin/ChangeLog | 8 +++++++- winsup/cygwin/signal.cc | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bc40e20a5..8ddb86120 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,4 +1,10 @@ -2003-01-10 Thomas Pfaff +2003-01-14 Thomas Pfaff + + * signal.cc (sleep): Add pthread_testcancel call. + Wait for signal and cancellation event. + (usleep): Ditto. + +2003-01-14 Thomas Pfaff * exceptions.cc (handle_sigsuspend): Add pthread_testcancel call. Wait for signal and cancellation event. diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index a23487fc3..c85290712 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -74,12 +74,14 @@ sleep (unsigned int seconds) sigframe thisframe (mainthread); DWORD ms, start_time, end_time; + pthread_testcancel (); + ms = seconds * 1000; start_time = GetTickCount (); end_time = start_time + (seconds * 1000); syscall_printf ("sleep (%d)", seconds); - rc = WaitForSingleObject (signal_arrived, ms); + rc = pthread::cancelable_wait (signal_arrived, ms); DWORD now = GetTickCount (); if (rc == WAIT_TIMEOUT || now >= end_time) ms = 0; @@ -97,9 +99,11 @@ sleep (unsigned int seconds) extern "C" unsigned int usleep (unsigned int useconds) { + pthread_testcancel (); + sig_dispatch_pending (0); syscall_printf ("usleep (%d)", useconds); - WaitForSingleObject (signal_arrived, (useconds + 500) / 1000); + pthread::cancelable_wait (signal_arrived, (useconds + 500) / 1000); syscall_printf ("0 = usleep (%d)", useconds); return 0; }