* fhandler_windows.cc (fhandler_windows::read): Use

pthread::get_cancel_event to fetch thread's cancel event.
	* flock.cc (lf_setlock): Ditto.
	* posix_ipc.cc (ipc_cond_timedwait): Ditto.
	* thread.cc (pthread::get_cancel_event): New static method.
	* thread.h (pthread::get_cancel_event): Declare.
This commit is contained in:
Corinna Vinschen 2011-05-01 17:42:41 +00:00
parent 1112b2c38f
commit a91ac4dca9
6 changed files with 28 additions and 13 deletions

View File

@ -1,3 +1,12 @@
2011-05-01 Corinna Vinschen <corinna@vinschen.de>
* fhandler_windows.cc (fhandler_windows::read): Use
pthread::get_cancel_event to fetch thread's cancel event.
* flock.cc (lf_setlock): Ditto.
* posix_ipc.cc (ipc_cond_timedwait): Ditto.
* thread.cc (pthread::get_cancel_event): New static method.
* thread.h (pthread::get_cancel_event): Declare.
2011-05-01 Corinna Vinschen <corinna@vinschen.de>
* libc/minires-os-if.c (get_dns_info): Remove unnecessary test for

View File

@ -98,10 +98,8 @@ fhandler_windows::read (void *buf, size_t& len)
HANDLE w4[3] = { get_handle (), signal_arrived, NULL };
DWORD cnt = 2;
pthread_t thread = pthread::self ();
if (thread && thread->cancel_event
&& thread->cancelstate != PTHREAD_CANCEL_DISABLE)
w4[cnt++] = thread->cancel_event;
if ((w4[cnt] = pthread::get_cancel_event ()) != NULL)
++cnt;
restart:
switch (MsgWaitForMultipleObjectsEx (cnt, w4,
is_nonblocking () ? 0 : INFINITE,

View File

@ -958,10 +958,7 @@ lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl)
return EDEADLK;
}
pthread_t thread = pthread::self ();
HANDLE cancel_event = (thread && thread->cancel_event
&& thread->cancelstate != PTHREAD_CANCEL_DISABLE)
? thread->cancel_event : NULL;
HANDLE cancel_event = pthread::get_cancel_event ();
int wait_count = 0;
/* The lock is always the first object. */

View File

@ -174,16 +174,13 @@ ipc_cond_init (HANDLE *pevt, const char *name, char sr)
static int
ipc_cond_timedwait (HANDLE evt, HANDLE mtx, const struct timespec *abstime)
{
pthread_t thread;
HANDLE w4[4] = { evt, signal_arrived, NULL, NULL };
DWORD cnt = 2;
DWORD timer_idx = 0;
int ret = 0;
thread = pthread::self ();
if (thread && thread->cancel_event
&& thread->cancelstate != PTHREAD_CANCEL_DISABLE)
w4[cnt++] = thread->cancel_event;
if ((w4[cnt] = pthread::get_cancel_event ()) != NULL)
++cnt;
if (abstime)
{
if (abstime->tv_sec < 0

View File

@ -885,6 +885,19 @@ pthread::testcancel ()
}
}
/* Return cancel event handle if it exists *and* cancel is not disabled.
This function is supposed to be used from other functions which are
cancelable and need the cancel event in a WFMO call. */
HANDLE
pthread::get_cancel_event ()
{
pthread_t thread = pthread::self ();
return (thread && thread->cancel_event
&& thread->cancelstate != PTHREAD_CANCEL_DISABLE)
? thread->cancel_event : NULL;
}
void
pthread::static_cancel_self ()
{

View File

@ -399,6 +399,7 @@ public:
virtual int cancel ();
virtual void testcancel ();
static HANDLE get_cancel_event ();
static void static_cancel_self ();
virtual int setcancelstate (int state, int *oldstate);