VirtualBox

Changeset 1653 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 23, 2007 10:14:23 AM (18 years ago)
Author:
vboxsync
Message:

More overlapped changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/DrvNamedPipe.cpp

    r1652 r1653  
    8080    RTFILE              NamedPipe;
    8181    /* Dummy overlapped structure. */
    82     OVERLAPPED          Overlapped;
     82    OVERLAPPED          OverlappedWrite;
     83    /* Overlapped structure for reads. */
     84    OVERLAPPED          OverlappedRead;
    8385#else /* !__WIN__ */
    8486    /** Socket handle of the local socket for server. */
     
    112114    {
    113115        unsigned cbReallyRead;
    114         rc = RTFileRead(pData->NamedPipe, pvBuf, *cbRead, &cbReallyRead);
     116        pData->OverlappedRead.Offset     = 0;
     117        pData->OverlappedRead.OffsetHigh = 0;
     118        if (!ReadFile((HANDLE)pData->NamedPipe, pvBuf, *cbRead, NULL, &pData->OverlappedRead))
     119        {
     120            DWORD uError = GetLastError();
     121
     122            if (uError == ERROR_IO_PENDING)
     123            {
     124                /* Wait for incoming bytes. */
     125                if (GetOverlappedResult((HANDLE)pData->NamedPipe, &pData->OverlappedRead, (DWORD *)&cbReallyRead, TRUE) == FALSE)
     126                {
     127                    uError = GetLastError();
     128                }
     129            }
     130
     131            rc = RTErrConvertFromWin32(uError);
     132
     133            Log(("drvNamedPipeRead: WriteFile returned %d (%Vrc)\n", uError, rc));
     134        }
     135
    115136        if (VBOX_FAILURE(rc))
    116137        {
     
    174195    {
    175196        unsigned cbWritten;
    176         pData->Overlapped.Offset     = 0;
    177         pData->Overlapped.OffsetHigh = 0;
    178         if (!WriteFile((HANDLE)pData->NamedPipe, pvBuf, *cbWrite, NULL, &pData->Overlapped))
     197        pData->OverlappedWrite.Offset     = 0;
     198        pData->OverlappedWrite.OffsetHigh = 0;
     199        if (!WriteFile((HANDLE)pData->NamedPipe, pvBuf, *cbWrite, NULL, &pData->OverlappedWrite))
    179200        {
    180201            DWORD uError = GetLastError();
     
    395416    }
    396417
    397     memset(&pData->Overlapped, 0, sizeof(pData->Overlapped));
    398     pData->Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
     418    memset(&pData->OverlappedWrite, 0, sizeof(pData->OverlappedWrite));
     419    memset(&pData->OverlappedRead, 0, sizeof(pData->OverlappedRead));
     420    pData->OverlappedWrite.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
     421    pData->OverlappedRead.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    399422
    400423#else /* !__WIN__ */
     
    465488
    466489        RTFileClose(pData->NamedPipe);
    467         CloseHandle(pData->Overlapped.hEvent);
     490        CloseHandle(pData->OverlappedRead.hEvent);
     491        CloseHandle(pData->OverlappedWrite.hEvent);
    468492    }
    469493#else /* !__WIN__ */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette