VirtualBox

Changeset 22193 in vbox


Ignore:
Timestamp:
Aug 12, 2009 7:23:29 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
50979
Message:

NAT: Moving splitting slirp_output to experimental (disabled) code and restoration of old behaviour

File:
1 edited

Legend:

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

    r22192 r22193  
    6262#define VBOX_NAT_DELAY_HACK
    6363#if 0
     64#define SLIRP_SPLIT_CAN_OUTPUT 1
    6465#define SLIRP_CAN_SAND_IN_PDM 1
    6566#define SLIRP_FLUSH_DEV 1
     
    168169    STAMCOUNTER             StatQueuePktSent;       /**< counting packet sent via PDM queue */
    169170    STAMCOUNTER             StatQueuePktDropped;    /**< counting packet drops by PDM queue */
     171#ifdef SLIRP_FLUSH_DEV
     172    PPDMTHREAD              pPDMQueueFlusher;
     173    RTSEMEVENT              semPDMQueueFlusher;
     174#endif
     175    int     output_flag;
    170176} DRVNAT;
    171177/** Pointer the NAT driver instance data. */
     
    533539
    534540#endif /* VBOX_WITH_SLIRP_MT */
     541#ifdef SLIRP_FLUSH_DEV
     542static DECLCALLBACK(int) drvNATPDMQueueFlusher(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
     543{
     544    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
     545    if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
     546        return VINF_SUCCESS;
     547    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
     548        {
     549        pThis->output_flag = 0;
     550        PDMQueueFlush(pThis->pSendQueue);
     551        pThis->output_flag = 1;
     552        RTSemEventWait(pThis->semPDMQueueFlusher, RT_INDEFINITE_WAIT);
     553        }
     554    return VINF_SUCCESS;
     555}
     556
     557
     558static DECLCALLBACK(int) drvNATPDMQueueFlusherWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
     559{
     560    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
     561
     562    return VINF_SUCCESS;
     563}
     564#endif
    535565
    536566/**
     
    541571int slirp_can_output(void *pvUser)
    542572{
    543 #ifdef SLIRP_CAN_SAND_IN_PDM
     573#ifdef SLIRP_SPLIT_CAN_OUTPUT
     574# ifdef SLIRP_CAN_SAND_IN_PDM
    544575    int status = 0;
    545576    int rc = 0;
     
    554585        rc = RTSemEventWait(pThis->semStatus, RT_INDEFINITE_WAIT);
    555586        AssertRC(rc);
    556         return status;
     587        return status & pThis->output_flag;
    557588    }
    558589    return 0;
     590# else
     591   PDRVNAT pThis = (PDRVNAT)pvUser;
     592   return (RT_SUCCESS(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0))? 1 : 0) & pThis->output_flag;
     593# endif
    559594#else
    560    PDRVNAT pThis = (PDRVNAT)pvUser;
    561    return (RT_SUCCESS(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0))? 1 : 0);
     595    return 1;
    562596#endif
    563597}
     
    567601#ifdef SLIRP_FLUSH_DEV
    568602    PDRVNAT pThis = (PDRVNAT)pvUser;
    569     /*@todo: idealy should be done in other thread */
    570     PDMQueueFlush(pThis->pSendQueue);
     603    RTSemEventSignal(pThis->semPDMQueueFlusher);
    571604#endif
    572605}
     
    632665    switch (pItem->enmType) {
    633666        case SLIRP_SEND:
     667#ifndef SLIRP_SPLIT_CAN_OUTPUT
     668            if (RT_FAILURE(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0)))
     669                return false;
     670#endif
    634671            rc = pThis->pPort->pfnReceive(pThis->pPort, pItem->pu8Buf, pItem->cb);
    635672            RTMemFree((void *)pItem->pu8Buf);
     
    9821019            rc = RTSemEventCreate(&pThis->semStatus);
    9831020            AssertRC(rc);
     1021            pThis->output_flag = 1;
     1022#ifdef SLIRP_FLUSH_DEV
     1023            rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pPDMQueueFlusher, pThis, drvNATPDMQueueFlusher,
     1024                                          drvNATPDMQueueFlusherWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT-PDMFLUSHER");
     1025            AssertReleaseRC(rc);
     1026            rc = RTSemEventCreate(&pThis->semPDMQueueFlusher);
     1027#endif
    9841028
    9851029#ifndef RT_OS_WINDOWS
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