include/llfio/v2.0/detail/impl/windows/import.hpp
// Wait for an overlapped handle to complete a specific operation
Wait for an overlapped handle to complete a specific operation
Wait for an overlapped handle to complete a specific operation
inline NTSTATUS ntwait(HANDLE h, windows_nt_kernel::IO_STATUS_BLOCK &isb, const deadline &d) noexcept
{
  windows_nt_kernel::init();
  using namespace windows_nt_kernel;
  if(isb.Status != 0x103 )
  {
    assert(isb.Status != -1);  
    return isb.Status;
  }
  LLFIO_WIN_DEADLINE_TO_SLEEP_INIT(d);
  do  
  {
    LLFIO_WIN_DEADLINE_TO_SLEEP_LOOP(d);
    NTSTATUS ntstat = NtWaitForSingleObject(h, 0u, timeout);
    if(STATUS_TIMEOUT == ntstat)
    {
      ntstat = ntcancel_pending_io(h, isb);
      if(ntstat < 0 && ntstat != (NTSTATUS) 0xC0000120 )
      {
        LLFIO_LOG_FATAL(nullptr, "Failed to cancel earlier i/o");
        abort();
      }
      isb.Status = ntstat = STATUS_TIMEOUT;
      return ntstat;
    }
  } while(isb.Status == 0x103 );
  return isb.Status;
}
inline NTSTATUS ntwait ( HANDLE h , windows_nt_kernel :: IO_STATUS_BLOCK & isb , const deadline & d ) noexcept { windows_nt_kernel :: init ( ) ; using namespace windows_nt_kernel ; if ( isb . Status != 0x103 ) { assert ( isb . Status != -1 ) ; return isb . Status ; } LLFIO_WIN_DEADLINE_TO_SLEEP_INIT ( d ) ; do { LLFIO_WIN_DEADLINE_TO_SLEEP_LOOP ( d ) ; NTSTATUS ntstat = NtWaitForSingleObject ( h , 0u , timeout ) ; if ( STATUS_TIMEOUT == ntstat ) { ntstat = ntcancel_pending_io ( h , isb ) ; if ( ntstat < 0 && ntstat != ( NTSTATUS ) 0xC0000120 ) { LLFIO_LOG_FATAL ( nullptr , " " ) ; abort ( ) ; } isb . Status = ntstat = STATUS_TIMEOUT ; return ntstat ; } } while ( isb . Status == 0x103 ) ; return isb . Status ; }
Wait for an overlapped handle to complete a specific operation
Wait for an overlapped handle to complete a specific operation
/*STATUS_PENDING*/ // should not call ntwait() if operation failed to start // He's done already (or never started) // needs to be a do, not while in order to flip auto reset event objects etc. // If he'll still pending, we must cancel the i/o /*STATUS_CANCELLED*/ /*STATUS_PENDING*/