VirtualBox

Changeset 22201 in vbox for trunk/src


Ignore:
Timestamp:
Aug 12, 2009 11:10:15 AM (15 years ago)
Author:
vboxsync
Message:

NAT: updated experimental pdmqueue flusher (disabled)

File:
1 edited

Legend:

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

    r22193 r22201  
    6262#define VBOX_NAT_DELAY_HACK
    6363#if 0
     64#define SLIRP_CAN_SAND_IN_PDM 1
    6465#define SLIRP_SPLIT_CAN_OUTPUT 1
    65 #define SLIRP_CAN_SAND_IN_PDM 1
    6666#define SLIRP_FLUSH_DEV 1
    6767#endif
     
    177177/** Pointer the NAT driver instance data. */
    178178typedef DRVNAT *PDRVNAT;
     179
     180#ifdef SLIRP_FLUSH_DEV
     181static DECLCALLBACK(int) drvNATPDMQueueFlusher(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
     182 {
     183    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
     184    if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
     185        return VINF_SUCCESS;
     186    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
     187        {
     188        int rc = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0);
     189        int new_flag = RT_SUCCESS(rc) ? 1 : 0;
     190
     191        if (pThis->output_flag == 0 && new_flag == 1)
     192        {
     193            int rc;
     194            pThis->output_flag = new_flag;
     195            /*we need inform NAT thread*/
     196#ifndef RT_OS_WINDOWS
     197            /* kick select() */
     198            rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL);
     199            AssertRC(rc);
     200#else
     201            /* kick WSAWaitForMultipleEvents */
     202            rc = WSASetEvent(pThis->hWakeupEvent);
     203            AssertRelease(rc == TRUE);
     204#endif
     205        }
     206        if (new_flag == 0)
     207        {
     208            pThis->output_flag = 0;
     209            goto flusher_sleeping; /*flushing won't give any results */
     210        }
     211        pThis->output_flag = 0;
     212        PDMQueueFlush(pThis->pSendQueue);
     213        rc = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0);
     214        pThis->output_flag = RT_SUCCESS(rc) ? 1 : 0;
     215    flusher_sleeping:
     216        RTSemEventWait(pThis->semPDMQueueFlusher, RT_INDEFINITE_WAIT);
     217        }
     218    return VINF_SUCCESS;
     219}
     220
     221
     222static DECLCALLBACK(int) drvNATPDMQueueFlusherWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
     223{
     224    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
     225    int rc = RTSemEventSignal(pThis->semPDMQueueFlusher);
     226    AssertReleaseRC(rc);
     227    return VINF_SUCCESS;
     228}
     229#endif
    179230
    180231/**
     
    487538# endif
    488539#endif /* RT_OS_WINDOWS */
     540        drvNATPDMQueueFlusherWakeup(pThis->pDrvIns, pThis->pPDMQueueFlusher);
    489541    }
    490542
     
    539591
    540592#endif /* VBOX_WITH_SLIRP_MT */
    541 #ifdef SLIRP_FLUSH_DEV
    542 static 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 
    558 static DECLCALLBACK(int) drvNATPDMQueueFlusherWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
    559 {
    560     PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
    561 
    562     return VINF_SUCCESS;
    563 }
    564 #endif
    565593
    566594/**
     
    590618# else
    591619   PDRVNAT pThis = (PDRVNAT)pvUser;
    592    return (RT_SUCCESS(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0))? 1 : 0) & pThis->output_flag;
     620   //drvNATPDMQueueFlusherWakeup(pThis->pDrvIns, pThis->pPDMQueueFlusher);
     621   return pThis->output_flag;
    593622# endif
    594623#else
     
    600629{
    601630#ifdef SLIRP_FLUSH_DEV
     631#if 0
    602632    PDRVNAT pThis = (PDRVNAT)pvUser;
    603     RTSemEventSignal(pThis->semPDMQueueFlusher);
     633    drvNATPDMQueueFlusherWakeup(pThis->pDrvIns, pThis->pPDMQueueFlusher);
     634#endif
    604635#endif
    605636}
     
    10191050            rc = RTSemEventCreate(&pThis->semStatus);
    10201051            AssertRC(rc);
    1021             pThis->output_flag = 1;
     1052            pThis->output_flag = 0;
    10221053#ifdef SLIRP_FLUSH_DEV
    10231054            rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pPDMQueueFlusher, pThis, drvNATPDMQueueFlusher,
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