Changeset 11116


Ignore:
Timestamp:
Oct 17, 2008, 10:46:58 AM (11 years ago)
Author:
gb
Message:

in lisp_read(): don't block in GetOverlappedResult?, since that doesn't
wait in "an alertable wait state"; do wait on the event handle, since
doing so is alertable.

File:
1 edited

Legend:

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

    r11096 r11116  
    284284  HANDLE hevent;
    285285  OVERLAPPED overlapped;
    286   DWORD err, nread;
     286  DWORD err, nread, wait_result;
    287287  pending_io pending;
    288288  TCR *tcr;
    289 
     289 
    290290 
    291291  memset(&overlapped,0,sizeof(overlapped));
     
    301301  hevent = (HANDLE)(tcr->io_datum);
    302302  overlapped.hEvent = hevent;
    303   do {
    304     ResetEvent(hevent);
    305     if (ReadFile(hfile, buf, count, &nread, &overlapped)) {
    306       tcr->pending_io_info = NULL;
    307       return nread;
    308     }
    309     err = GetLastError();
    310 
     303  ResetEvent(hevent);
     304  if (ReadFile(hfile, buf, count, &nread, &overlapped)) {
     305    tcr->pending_io_info = NULL;
     306    return nread;
     307  }
     308  err = GetLastError();
     309 
     310  if (err == ERROR_HANDLE_EOF) {
     311    tcr->pending_io_info = NULL;
     312    return 0;
     313  }
     314
     315  if (err != ERROR_IO_PENDING) {
     316    _dosmaperr(err);
     317    tcr->pending_io_info = NULL;
     318    return -1;
     319  }
     320 
     321  err = 0;
     322 
     323  /* We block here */   
     324  wait_result = WaitForSingleObjectEx(hevent, INFINITE, true);
     325  tcr->pending_io_info = NULL;
     326  if (wait_result == WAIT_OBJECT_0) {
     327    err = overlapped.Internal;
    311328    if (err == ERROR_HANDLE_EOF) {
    312       tcr->pending_io_info = NULL;
    313329      return 0;
    314330    }
    315 
    316     if (err != ERROR_IO_PENDING) {
     331    if (err) {
    317332      _dosmaperr(err);
    318       tcr->pending_io_info = NULL;
    319333      return -1;
    320334    }
     335    return overlapped.InternalHigh;
     336  }
     337
     338  if (wait_result == WAIT_IO_COMPLETION) {
     339    CancelIo(hfile);
     340    errno = EINTR;
     341    return -1;
     342  }
     343  err = GetLastError();
    321344 
    322     err = 0;
    323     /* We block here */
    324     if (GetOverlappedResult(hfile, &overlapped, &nread, TRUE)) {
    325       if (nread) {
    326         tcr->pending_io_info = NULL;
    327         return nread;
    328       }
    329     } else {
    330       err = GetLastError();
    331     }
    332   } while (!err);
    333   tcr->pending_io_info = NULL;
    334345
    335346  switch (err) {
Note: See TracChangeset for help on using the changeset viewer.