Changeset 11956


Ignore:
Timestamp:
Apr 18, 2009, 9:52:29 AM (11 years ago)
Author:
gb
Message:

Try to handle overlapped I/O in lisp_write(), too.

File:
1 edited

Legend:

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

    r11603 r11956  
    350350  HANDLE hevent;
    351351  OVERLAPPED overlapped;
    352   DWORD err, nwritten;
     352  DWORD err, nwritten, wait_result;
     353  pending_io pending;
    353354  TCR *tcr = (TCR *)get_tcr(1);
    354355
     
    367368  }
    368369
     370
     371  pending.h = hfile;
     372  pending.o = &overlapped;
     373  tcr->pending_io_info = &pending;
    369374  overlapped.hEvent = hevent;
    370375  ResetEvent(hevent);
    371376  if (WriteFile(hfile, buf, count, &nwritten, &overlapped)) {
     377    tcr->pending_io_info = NULL;
    372378    return nwritten;
    373379  }
    374380 
     381  err = GetLastError();
     382  if (err != ERROR_IO_PENDING) {
     383    _dosmaperr(err);
     384    tcr->pending_io_info = NULL;
     385    return -1;
     386  }
     387  err = 0;
     388  wait_result = WaitForSingleObjectEx(hevent, INFINITE, true);
     389  tcr->pending_io_info = NULL;
     390  if (wait_result == WAIT_OBJECT_0) {
     391    err = overlapped.Internal;
     392    if (err) {
     393      _dosmaperr(err);
     394      return -1;
     395    }
     396    return overlapped.InternalHigh;
     397  }
     398  if (wait_result == WAIT_IO_COMPLETION) {
     399    CancelIo(hfile);
     400    errno = EINTR;
     401    return -1;
     402  }
    375403  err = GetLastError();
    376404  _dosmaperr(err);
Note: See TracChangeset for help on using the changeset viewer.