VirtualBox

Changeset 14189 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 13, 2008 5:13:12 PM (16 years ago)
Author:
vboxsync
Message:

NAT: better error handling

File:
1 edited

Legend:

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

    r14121 r14189  
    121121    int rc;
    122122    /*notify select to wakeup*/
    123     memcpy(pThis->cBuffer,pvBuf, cb);
     123    AssertRelease(cb <= sizeof(pThis->cBuffer));
     124    memcpy(pThis->cBuffer, pvBuf, cb);
    124125    pThis->sBufferSize = cb;
    125126# ifndef RT_OS_WINDOWS
     
    180181    LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState));
    181182
     183    LogRel(("drvNATNotifyLinkChanged\n"));
    182184#ifndef VBOX_WITH_SIMPLEFIED_SLIRP_SYNC
    183185    int rc = RTCritSectEnter(&pThis->CritSect);
     
    244246    fd_set  XcptFDs;
    245247    int     nFDs = -1;
    246     int     rc;
    247248# ifdef RT_OS_WINDOWS
    248249    DWORD   event;
     
    256257    if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
    257258        return VINF_SUCCESS;
     259
     260#ifdef RT_OS_WINDOWS
     261    phEvents = slirp_get_events(pThis->pNATState);
     262#endif
    258263
    259264    /*
     
    302307        }
    303308# else /* RT_OS_WINDOWS */
    304         phEvents = slirp_get_events(pThis->pNATState);
    305309        event = WSAWaitForMultipleEvents(nFDs, phEvents, FALSE, 2 /*ms*/, FALSE);
    306         AssertRelease(event != WSA_WAIT_FAILED);
    307 
    308         if (event == WSA_WAIT_TIMEOUT) {
     310        if (   (event < WSA_WAIT_EVENT_0 || event > WSA_WAIT_EVENT_0 + nFDs - 1)
     311            && event != WSA_WAIT_TIMEOUT)
     312        {
     313            int error = WSAGetLastError();
     314            LogRel(("WSAWaitForMultipleEvents returned %d (error %d)\n", event, error));
     315            RTAssertReleasePanic();
     316        }
     317
     318        if (event == WSA_WAIT_TIMEOUT)
     319        {
    309320            slirp_select_poll(pThis->pNATState, NULL, NULL, NULL);
    310             continue;
    311         }
     321            continue;
     322        }
    312323
    313324        /*
    314325         * see WSAWaitForMultipleEvents documentation: return value is a minimal index in array
    315326         */
    316         if ((event - WSA_WAIT_EVENT_0) > 0) {
     327        if ((event - WSA_WAIT_EVENT_0) > 0)
    317328            slirp_select_poll(pThis->pNATState, &ReadFDs, &WriteFDs, &XcptFDs);
    318         }
    319329
    320330        if ((event - WSA_WAIT_EVENT_0) == 0)
     
    696706# else
    697707            pThis->hSendEvent = WSACreateEvent();
    698             slirp_register_external_event(pThis->pNATState, pThis->hSendEvent);
     708            slirp_register_external_event(pThis->pNATState, pThis->hSendEvent);
    699709# endif
    700710
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