VirtualBox

Changeset 27510 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 19, 2010 1:37:08 AM (15 years ago)
Author:
vboxsync
Message:

poll-win.cpp,socket.cpp: Tested socket polling for windows.

Location:
trunk/src/VBox/Runtime/r3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/socket.cpp

    r27509 r27510  
    156156#endif
    157157} RTSOCKADDRUNION;
    158 
    159 
    160 /*******************************************************************************
    161 *   Internal Functions                                                         *
    162 *******************************************************************************/
    163158
    164159
     
    909904
    910905/**
     906 * Undos the harm done by WSAEventSelect.
     907 *
     908 * @returns IPRT status code.
     909 * @param   pThis               The socket handle.
     910 */
     911static int rtSocketPollClearEventAndMakeBlocking(RTSOCKETINT *pThis)
     912{
     913    int rc = VINF_SUCCESS;
     914    if (pThis->fSubscribedEvts)
     915    {
     916        if (WSAEventSelect(pThis->hNative, WSA_INVALID_EVENT, 0) == 0)
     917        {
     918            pThis->fSubscribedEvts = 0;
     919
     920            u_long fNonBlocking = 0;
     921            int rc2 = ioctlsocket(pThis->hNative, FIONBIO, &fNonBlocking);
     922            if (rc2 != 0)
     923            {
     924                rc = rtSocketError();
     925                AssertMsgFailed(("%Rrc; rc2=%d\n", rc, rc2));
     926            }
     927        }
     928        else
     929        {
     930            rc = rtSocketError();
     931            AssertMsgFailed(("%Rrc\n", rc));
     932        }
     933    }
     934    return rc;
     935}
     936
     937
     938/**
    911939 * Updates the mask of events we're subscribing to.
    912940 *
     
    927955    {
    928956        pThis->fSubscribedEvts = fEvents;
    929 
    930         u_long fNonBlocking = 0;
    931         if (ioctlsocket(pThis->hNative, FIONBIO, &fNonBlocking))
    932             AssertMsgFailed(("%Rrc\n", rtSocketError()));
    933 
    934957        return VINF_SUCCESS;
    935958    }
     
    10521075    {
    10531076        if (pThis->cUsers == 1)
     1077        {
     1078            rtSocketPollClearEventAndMakeBlocking(pThis);
    10541079            pThis->hPollSet = NIL_RTPOLLSET;
     1080        }
    10551081        ASMAtomicDecU32(&pThis->cUsers);
    10561082    }
     
    10871113    pThis->fPollEvts = 0;
    10881114
    1089     /* unlock the socket. */
     1115    /* Make the socket blocking again and unlock the handle. */
    10901116    if (pThis->cUsers == 1)
     1117    {
     1118        rtSocketPollClearEventAndMakeBlocking(pThis);
    10911119        pThis->hPollSet = NIL_RTPOLLSET;
     1120    }
    10921121    ASMAtomicDecU32(&pThis->cUsers);
    10931122    return fRetEvents;
  • trunk/src/VBox/Runtime/r3/win/poll-win.cpp

    r27509 r27510  
    197197    if (    dwRc >= WAIT_OBJECT_0
    198198        &&  dwRc <  WAIT_OBJECT_0 + cHandles)
    199         rc = VINF_SUCCESS;
     199        rc = VERR_INTERRUPTED;
    200200    else if (dwRc == WAIT_TIMEOUT)
    201201        rc = VERR_TIMEOUT;
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