VirtualBox

Changeset 71950 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 20, 2018 9:31:06 PM (7 years ago)
Author:
vboxsync
Message:

socket.cpp: Windows polling fixes for problem where we got stuck returning RTPOLL_EVT_READ.

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

Legend:

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

    r71949 r71950  
    164164    uint32_t            fSubscribedEvts;
    165165    /** Saved events which are only posted once and events harvested for
    166      * sockets entetered multiple times into to a poll set. */
     166     * sockets entered multiple times into to a poll set.   Imagine a scenario where
     167     * you have a RTPOLL_EVT_READ entry and RTPOLL_EVT_ERROR entry.  The READ
     168     * condition can be triggered between checking the READ entry and the ERROR
     169     * entry, and we don't want to drop the READ, so we store it here and make sure
     170     * the event is signalled.
     171     *
     172     * The RTPOLL_EVT_ERROR is inconsistenly sticky at the momemnt... */
    167173    uint32_t            fEventsSaved;
    168     /** Set if fEventsSaved contains harvested events. */
     174    /** Set if fEventsSaved contains harvested events (used to avoid multiple
     175     *  calls to rtSocketPollCheck on the same socket during rtSocketPollDone). */
    169176    bool                fHarvestedEvents;
    170177    /** Set if we're using the polling fallback. */
     
    28432850
    28442851            pThis->fEventsSaved = fRetEvents |= pThis->fEventsSaved;
     2852            fRetEvents &= fEvents | RTPOLL_EVT_ERROR;
    28452853        }
    28462854        else
     
    29572965    {
    29582966        pThis->fPollEvts |= fEvents;
    2959         if (   fFinalEntry
    2960             && pThis->fSubscribedEvts != pThis->fPollEvts)
    2961         {
    2962             int rc = rtSocketPollUpdateEvents(pThis, pThis->fPollEvts);
    2963             if (RT_FAILURE(rc))
     2967        if (fFinalEntry)
     2968        {
     2969            if (pThis->fSubscribedEvts != pThis->fPollEvts)
    29642970            {
    2965                 pThis->fPollEvts = 0;
    2966                 fRetEvents       = UINT32_MAX;
     2971                /** @todo seems like there migth be a call to many here and that fPollEvts is
     2972                 *        totally unnecessary... (bird) */
     2973                int rc = rtSocketPollUpdateEvents(pThis, pThis->fPollEvts);
     2974                if (RT_FAILURE(rc))
     2975                {
     2976                    pThis->fPollEvts = 0;
     2977                    fRetEvents       = UINT32_MAX;
     2978                }
    29672979            }
     2980
     2981            /* Make sure we don't block when there are events pending relevant to an earlier poll set entry. */
     2982            if (pThis->fEventsSaved && !pThis->fPollFallback && g_pfnWSASetEvent && fRetEvents == 0)
     2983                g_pfnWSASetEvent(pThis->hEvent);
    29682984        }
    29692985    }
     
    29772993        {
    29782994# ifdef RT_OS_WINDOWS
     2995            pThis->fEventsSaved    &= RTPOLL_EVT_ERROR;
     2996            pThis->fHarvestedEvents = false;
    29792997            rtSocketPollClearEventAndRestoreBlocking(pThis);
    29802998# endif
    29812999            pThis->hPollSet = NIL_RTPOLLSET;
    29823000        }
     3001# ifdef RT_OS_WINDOWS
     3002        else
     3003            pThis->fHarvestedEvents = true;
     3004# endif
    29833005        ASMAtomicDecU32(&pThis->cUsers);
    29843006    }
     
    30693091    {
    30703092# ifdef RT_OS_WINDOWS
    3071         pThis->fEventsSaved   &= RTPOLL_EVT_ERROR;
     3093        pThis->fEventsSaved    &= RTPOLL_EVT_ERROR;
    30723094        pThis->fHarvestedEvents = false;
    30733095        rtSocketPollClearEventAndRestoreBlocking(pThis);
  • trunk/src/VBox/Runtime/r3/win/init-win.cpp

    r71150 r71950  
    103103/** WSACloseEvent  */
    104104DECLHIDDEN(PFNWSACLOSEEVENT)                g_pfnWSACloseEvent = NULL;
     105/** WSASetEvent */
     106DECLHIDDEN(PFNWSASETEVENT)                  g_pfnWSASetEvent = NULL;
    105107/** WSAEventSelect   */
    106108DECLHIDDEN(PFNWSAEVENTSELECT)               g_pfnWSAEventSelect = NULL;
     
    363365    g_pfnWSACreateEvent       = (decltype(g_pfnWSACreateEvent))     GetProcAddress(g_hModWinSock, "WSACreateEvent");
    364366    g_pfnWSACloseEvent        = (decltype(g_pfnWSACloseEvent))      GetProcAddress(g_hModWinSock, "WSACloseEvent");
     367    g_pfnWSASetEvent          = (decltype(g_pfnWSASetEvent))        GetProcAddress(g_hModWinSock, "WSASetEvent");
    365368    g_pfnWSAEventSelect       = (decltype(g_pfnWSAEventSelect))     GetProcAddress(g_hModWinSock, "WSAEventSelect");
    366369    g_pfnWSAEnumNetworkEvents = (decltype(g_pfnWSAEnumNetworkEvents))GetProcAddress(g_hModWinSock,"WSAEnumNetworkEvents");
     
    392395    Assert(g_pfnWSACreateEvent       || g_fOldWinSock);
    393396    Assert(g_pfnWSACloseEvent        || g_fOldWinSock);
     397    Assert(g_pfnWSASetEvent          || g_fOldWinSock);
    394398    Assert(g_pfnWSAEventSelect       || g_fOldWinSock);
    395399    Assert(g_pfnWSAEnumNetworkEvents || g_fOldWinSock);
  • trunk/src/VBox/Runtime/r3/win/internal-r3-win.h

    r71150 r71950  
    125125/** WSACreateEvent */
    126126typedef HANDLE          (WINAPI *PFNWSACREATEEVENT)(void);
     127/** WSASetEvent */
     128typedef BOOL            (WINAPI *PFNWSASETEVENT)(HANDLE);
    127129/** WSACloseEvent */
    128130typedef BOOL            (WINAPI *PFNWSACLOSEEVENT)(HANDLE);
     
    179181extern DECLHIDDEN(PFNWSACREATEEVENT)               g_pfnWSACreateEvent;
    180182extern DECLHIDDEN(PFNWSACLOSEEVENT)                g_pfnWSACloseEvent;
     183extern DECLHIDDEN(PFNWSASETEVENT)                  g_pfnWSASetEvent;
    181184extern DECLHIDDEN(PFNWSAEVENTSELECT)               g_pfnWSAEventSelect;
    182185extern DECLHIDDEN(PFNWSAENUMNETWORKEVENTS)         g_pfnWSAEnumNetworkEvents;
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