Changeset 10831


Ignore:
Timestamp:
Sep 22, 2008, 3:31:18 PM (11 years ago)
Author:
gb
Message:

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 ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/thread_manager.c

    r10770 r10831  
    5050extern void interrupt_handler(int, siginfo_t *, ExceptionInformation *);
    5151
     52void CALLBACK
     53nullAPC(ULONG_PTR arg)
     54{
     55}
     56 
    5257BOOL (*pCancelIoEx)(HANDLE, OVERLAPPED*) = NULL;
    5358
     
    7782  rc = GetThreadContext(hthread, pcontext);
    7883  if (rc == 0) {
    79     wperror("GetThreadContext");
     84    return ESRCH;
    8085  }
    8186
     
    104109        CancelIo(pending->h);
    105110      }
    106     }
     111    } else {
     112      QueueUserAPC(nullAPC, hthread, 0);
     113    }
     114
    107115    ResumeThread(hthread);
    108116    return 0;
     
    456464#endif
    457465#ifdef USE_WINDOWS_SEMAPHORES
    458   switch (WaitForSingleObject(s, seconds*1000L+(DWORD)millis)) {
     466  switch (WaitForSingleObjectEx(s, seconds*1000L+(DWORD)millis,true)) {
    459467  case WAIT_OBJECT_0:
    460468    return 0;
    461469  case WAIT_TIMEOUT:
    462     return WAIT_TIMEOUT;
     470    return /* ETIMEDOUT */ WAIT_TIMEOUT;
     471  case WAIT_IO_COMPLETION:
     472    return EINTR;
    463473  default:
    464474    break;
     
    15591569    if (rc == -1) {
    15601570      /* If the thread's simply dead, we should handle that here */
    1561       wperror("SuspendThread");
    15621571      return false;
    15631572    }
     
    15651574    rc = GetThreadContext(hthread, pcontext);
    15661575    if (rc == 0) {
    1567       wperror("GetThreadContext");
     1576      return false;
    15681577    }
    15691578    where = (pc)(xpPC(pcontext));
Note: See TracChangeset for help on using the changeset viewer.