[Openmcl-cvs-notifications] r10831 - /trunk/source/lisp-kernel/thread_manager.c
gb at clozure.com
gb at clozure.com
Mon Sep 22 11:31:18 EDT 2008
Author: gb
Date: Mon Sep 22 11:31:18 2008
New Revision: 10831
Log:
When interrupting a thread running foreign code, "queue an
asynchronous procedure call" to the thread if it's not in
a blocking read in our I/O code. The APC's a noop, but
the act of queueing it will cause some "alertable" blocking
operations to return #$WAIT_IO_COMPLETION, which we can
try to treat as #$EINTR.)
We have no way that I know of of knowing if a thread's in "an
alertable wait state", so the APC might terminate the next
alertable blocking operation. Foreign code that does alertable
blocking operations should presumably not get too confused by
this, though we'd really like such code to return #$EINTR.
That might be too much to ask ...
Modified:
trunk/source/lisp-kernel/thread_manager.c
Modified: trunk/source/lisp-kernel/thread_manager.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/thread_manager.c (original)
+++ trunk/source/lisp-kernel/thread_manager.c Mon Sep 22 11:31:18 2008
@@ -49,6 +49,11 @@
=
extern void interrupt_handler(int, siginfo_t *, ExceptionInformation *);
=
+void CALLBACK =
+nullAPC(ULONG_PTR arg) =
+{
+}
+ =
BOOL (*pCancelIoEx)(HANDLE, OVERLAPPED*) =3D NULL;
=
=
@@ -76,7 +81,7 @@
pcontext->ContextFlags =3D CONTEXT_ALL;
rc =3D GetThreadContext(hthread, pcontext);
if (rc =3D=3D 0) {
- wperror("GetThreadContext");
+ return ESRCH;
}
=
where =3D (pc)(xpPC(pcontext));
@@ -103,7 +108,10 @@
} else {
CancelIo(pending->h);
}
- }
+ } else {
+ QueueUserAPC(nullAPC, hthread, 0);
+ }
+
ResumeThread(hthread);
return 0;
} else {
@@ -455,11 +463,13 @@
}
#endif
#ifdef USE_WINDOWS_SEMAPHORES
- switch (WaitForSingleObject(s, seconds*1000L+(DWORD)millis)) {
+ switch (WaitForSingleObjectEx(s, seconds*1000L+(DWORD)millis,true)) {
case WAIT_OBJECT_0:
return 0;
case WAIT_TIMEOUT:
- return WAIT_TIMEOUT;
+ return /* ETIMEDOUT */ WAIT_TIMEOUT;
+ case WAIT_IO_COMPLETION:
+ return EINTR;
default:
break;
}
@@ -1558,13 +1568,12 @@
rc =3D SuspendThread(hthread);
if (rc =3D=3D -1) {
/* If the thread's simply dead, we should handle that here */
- wperror("SuspendThread");
return false;
}
pcontext->ContextFlags =3D CONTEXT_ALL;
rc =3D GetThreadContext(hthread, pcontext);
if (rc =3D=3D 0) {
- wperror("GetThreadContext");
+ return false;
}
where =3D (pc)(xpPC(pcontext));
=
More information about the Openmcl-cvs-notifications
mailing list