VirtualBox

Changeset 14086 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Nov 11, 2008 12:06:26 PM (16 years ago)
Author:
vboxsync
Message:

array of 2 events replaced with 1 because the event array is managed by slirp
fixed index selector, which triggered _poll part of slirp in case of slirp opened 2 and more sockets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r14041 r14086  
    8787    RTFILE                  PipeRead;
    8888#else
    89     /* 1 - for Outher network events, and 0 for sending routine notification*/
    90     HANDLE                  hNetworkEvent[2];
     89    /*for send event from guest*/
     90    HANDLE                  hSendEvent;
    9191#endif
    9292    /** Send buffer */
     
    119119#ifdef VBOX_WITH_SIMPLEFIED_SLIRP_SYNC
    120120
     121    int rc;
    121122    /*notify select to wakeup*/
    122123    memcpy(pThis->cBuffer,pvBuf, cb);
    123124    pThis->sBufferSize = cb;
    124125# ifndef RT_OS_WINDOWS
    125     int rc = RTFileWrite(pThis->PipeWrite, "1", 2, NULL);
     126    rc = RTFileWrite(pThis->PipeWrite, "1", 2, NULL);
    126127    AssertRC(rc);
    127128# else
    128     WSASetEvent(pThis->hNetworkEvent[0]);
     129    rc = WSASetEvent(pThis->hSendEvent);
     130    AssertRelease(rc == TRUE);
    129131# endif
    130132    RTSemEventWait(pThis->semSndMutex, RT_INDEFINITE_WAIT);
     
    301303# else /* RT_OS_WINDOWS */
    302304        phEvents = slirp_get_events(pThis->pNATState);
    303         phEvents[0] = pThis->hNetworkEvent[0];
     305        phEvents[0] = pThis->hSendEvent;
    304306        event = WSAWaitForMultipleEvents(nFDs, phEvents, FALSE, 2 /*ms*/, FALSE);
    305307        AssertRelease(event != WSA_WAIT_FAILED);
     308
     309        if (event == WSA_WAIT_TIMEOUT) {
     310                continue;
     311        }
    306312
    307313        /*
    308314         * see WSAWaitForMultipleEvents documentation: return value is a minimal index in array
    309315         */
    310         if ((event - WSA_WAIT_EVENT_0) > 1)
     316        if ((event - WSA_WAIT_EVENT_0) > 0) {
    311317            slirp_select_poll(pThis->pNATState, &ReadFDs, &WriteFDs, &XcptFDs);
     318        }
    312319
    313320        if ((event - WSA_WAIT_EVENT_0) == 0)
    314321        {
    315322            /** XXX distinguish between drvNATSend and wakeup only */
    316             slirp_input(pThis->pNATState, (uint8_t *)pThis->cBuffer, pThis->sBufferSize);
    317             WSAResetEvent(pThis->hNetworkEvent[0]);
     323            slirp_input(pThis->pNATState, (uint8_t *)&pThis->cBuffer[0], pThis->sBufferSize);
     324            WSAResetEvent(pThis->hSendEvent);
    318325            RTSemEventSignal(pThis->semSndMutex);
    319326        }
    320         WSAResetEvent(pThis->hNetworkEvent[0]);
    321327# endif /* RT_OS_WINDOWS */
    322328    }
     
    689695            pThis->PipeWrite = fds[1];
    690696# else
    691             pThis->hNetworkEvent[0] = WSACreateEvent();
    692             pThis->hNetworkEvent[1] = WSACreateEvent();
     697            pThis->hSendEvent = WSACreateEvent();
    693698# endif
    694699
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