Ignore:
Timestamp:
Jun 12, 2002, 4:28:33 PM (23 years ago)
Author:
sandervl
Message:

If bytes present in COM device buffer, read them directly; even for overlapped IO calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmcomm.cpp

    r8644 r8652  
    1 /* $Id: hmcomm.cpp,v 1.35 2002-06-11 12:51:43 sandervl Exp $ */
     1/* $Id: hmcomm.cpp,v 1.36 2002-06-12 14:28:33 sandervl Exp $ */
    22
    33/*
     
    566566    }
    567567
    568     if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
     568    RXQUEUE qInfo;
     569    ULONG ulLen = sizeof(qInfo);
     570    ULONG rc = OSLibDosDevIOCtl(pHMHandleData->hHMHandle, IOCTL_ASYNC, ASYNC_GETINQUECOUNT, 0,0,0, &qInfo,ulLen,&ulLen);
     571    dprintf(("ASYNC_GETINQUECOUNT -> qInfo.cch %d (queue size %d) rc %d", qInfo.cch, qInfo.cb, rc));
     572
     573    if(!qInfo.cch && pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
    569574        return pDevData->iohandler->ReadFile(pHMHandleData->hWin32Handle, lpBuffer, nNumberOfBytesToRead,
    570575                                             lpNumberOfBytesRead, lpOverlapped, lpCompletionRoutine, (DWORD)pDevData);
    571576    }
    572 
    573 #ifdef DEBUG
    574     RXQUEUE qInfo;
    575     ULONG ulLen = sizeof(qInfo);
    576     ULONG rc = OSLibDosDevIOCtl(pHMHandleData->hHMHandle,
    577                                 IOCTL_ASYNC,
    578                                 ASYNC_GETINQUECOUNT,
    579                                 0,0,0,
    580                                 &qInfo,ulLen,&ulLen);
    581     dprintf(("ASYNC_GETINQUECOUNT -> qInfo.cch %d (queue size %d) rc %d", qInfo.cch, qInfo.cb, rc));
    582 #endif
    583577
    584578    ret = OSLibDosRead(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToRead,
     
    600594    }
    601595#endif
     596
     597    if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
     598        //reset overlapped semaphore to non-signalled
     599        ::ResetEvent(lpOverlapped->hEvent);
     600
     601        //set event to make sure next GetOverlappedResult doesn't block
     602        ::SetEvent(lpOverlapped->hEvent);
     603
     604        lpOverlapped->Internal     = GetLastError();
     605        lpOverlapped->InternalHigh = ulBytesRead;
     606    }
    602607    return ret;
    603608}
Note: See TracChangeset for help on using the changeset viewer.