VirtualBox

Ignore:
Timestamp:
Dec 1, 2011 7:59:21 PM (13 years ago)
Author:
vboxsync
Message:

RTReq refactoring.

File:
1 edited

Legend:

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

    r39465 r39498  
    154154    PPDMTHREAD              pSlirpThread;
    155155    /** Queue for NAT-thread-external events. */
    156     PRTREQQUEUE             pSlirpReqQueue;
     156    RTREQQUEUE              hSlirpReqQueue;
    157157    /** The guest IP for port-forwarding. */
    158158    uint32_t                GuestIP;
     
    185185    RTSEMEVENT              EventUrgRecv;
    186186    /** Receive Req queue (deliver packets to the guest) */
    187     PRTREQQUEUE             pRecvReqQueue;
     187    RTREQQUEUE              hRecvReqQueue;
    188188    /** Receive Urgent Req queue (deliver packets to the guest). */
    189     PRTREQQUEUE             pUrgRecvReqQueue;
     189    RTREQQUEUE              hUrgRecvReqQueue;
    190190
    191191    /** makes access to device func RecvAvail and Recv atomical. */
     
    219219    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    220220    {
    221         RTReqProcess(pThis->pRecvReqQueue, 0);
     221        RTReqQueueProcess(pThis->hRecvReqQueue, 0);
    222222        if (ASMAtomicReadU32(&pThis->cPkts) == 0)
    223223            RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT);
     
    246246    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    247247    {
    248         RTReqProcess(pThis->pUrgRecvReqQueue, 0);
     248        RTReqQueueProcess(pThis->hUrgRecvReqQueue, 0);
    249249        if (ASMAtomicReadU32(&pThis->cUrgPkts) == 0)
    250250        {
     
    535535
    536536#ifdef VBOX_WITH_SLIRP_MT
    537         PRTREQQUEUE pQueue = (PRTREQQUEUE)slirp_get_queue(pThis->pNATState);
     537        RTREQQUEUE hQueue = (RTREQQUEUE)slirp_get_queue(pThis->pNATState);
    538538#else
    539         PRTREQQUEUE pQueue = pThis->pSlirpReqQueue;
     539        RTREQQUEUE hQueue = pThis->hSlirpReqQueue;
    540540#endif
    541         rc = RTReqCallEx(pQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
    542                          (PFNRT)drvNATSendWorker, 2, pThis, pSgBuf);
     541        rc = RTReqQueueCallEx(hQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
     542                              (PFNRT)drvNATSendWorker, 2, pThis, pSgBuf);
    543543        if (RT_SUCCESS(rc))
    544544        {
     
    637637
    638638    PRTREQ pReq;
    639     int rc = RTReqCallEx(pThis->pSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID,
    640                          (PFNRT)drvNATNotifyLinkChangedWorker, 2, pThis, enmLinkState);
     639    int rc = RTReqQueueCallEx(pThis->hSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID,
     640                              (PFNRT)drvNATNotifyLinkChangedWorker, 2, pThis, enmLinkState);
    641641    if (RT_LIKELY(rc == VERR_TIMEOUT))
    642642    {
     
    684684    PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkNATCfg);
    685685    PRTREQ pReq;
    686     int rc = RTReqCallEx(pThis->pSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID,
    687                          (PFNRT)drvNATNotifyApplyPortForwardCommand, 7, pThis, fRemove,
    688                          fUdp, pHostIp, u16HostPort, pGuestIp, u16GuestPort);
     686    int rc = RTReqQueueCallEx(pThis->hSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID,
     687                              (PFNRT)drvNATNotifyApplyPortForwardCommand, 7, pThis, fRemove,
     688                              fUdp, pHostIp, u16HostPort, pGuestIp, u16GuestPort);
    689689    if (RT_LIKELY(rc == VERR_TIMEOUT))
    690690    {
     
    707707 * dedicated thread. We take care that this thread does not become the
    708708 * bottleneck: If the guest wants to send, a request is enqueued into the
    709  * pSlirpReqQueue and handled asynchronously by this thread.  If this thread
     709 * hSlirpReqQueue and handled asynchronously by this thread.  If this thread
    710710 * wants to deliver packets to the guest, it enqueues a request into
    711  * pRecvReqQueue which is later handled by the Recv thread.
     711 * hRecvReqQueue which is later handled by the Recv thread.
    712712 */
    713713static DECLCALLBACK(int) drvNATAsyncIoThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
     
    792792        }
    793793        /* process _all_ outstanding requests but don't wait */
    794         RTReqProcess(pThis->pSlirpReqQueue, 0);
     794        RTReqQueueProcess(pThis->hSlirpReqQueue, 0);
    795795        RTMemFree(polls);
    796796
     
    819819        slirp_select_poll(pThis->pNATState, /* fTimeout=*/false, /* fIcmp=*/(dwEvent == WSA_WAIT_EVENT_0));
    820820        /* process _all_ outstanding requests but don't wait */
    821         RTReqProcess(pThis->pSlirpReqQueue, 0);
     821        RTReqQueueProcess(pThis->hSlirpReqQueue, 0);
    822822# ifdef VBOX_NAT_DELAY_HACK
    823823        if (cBreak++ > 128)
     
    903903
    904904    ASMAtomicIncU32(&pThis->cUrgPkts);
    905     int rc = RTReqCallEx(pThis->pUrgRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
    906                          (PFNRT)drvNATUrgRecvWorker, 4, pThis, pu8Buf, cb, m);
     905    int rc = RTReqQueueCallEx(pThis->hUrgRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
     906                              (PFNRT)drvNATUrgRecvWorker, 4, pThis, pu8Buf, cb, m);
    907907    AssertRC(rc);
    908908    drvNATUrgRecvWakeup(pThis->pDrvIns, pThis->pUrgRecvThread);
     
    937937
    938938    ASMAtomicIncU32(&pThis->cPkts);
    939     int rc = RTReqCallEx(pThis->pRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
    940                          (PFNRT)drvNATRecvWorker, 4, pThis, pu8Buf, cb, m);
     939    int rc = RTReqQueueCallEx(pThis->hRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
     940                              (PFNRT)drvNATRecvWorker, 4, pThis, pu8Buf, cb, m);
    941941    AssertRC(rc);
    942942    drvNATRecvWakeup(pThis->pDrvIns, pThis->pRecvThread);
     
    11191119    }
    11201120
    1121     RTReqDestroyQueue(pThis->pSlirpReqQueue);
    1122     pThis->pSlirpReqQueue = NULL;
    1123 
    1124     RTReqDestroyQueue(pThis->pUrgRecvReqQueue);
    1125     pThis->pUrgRecvReqQueue = NULL;
     1121    RTReqQueueDestroy(pThis->hSlirpReqQueue);
     1122    pThis->hSlirpReqQueue = NIL_RTREQQUEUE;
     1123
     1124    RTReqQueueDestroy(pThis->hUrgRecvReqQueue);
     1125    pThis->hUrgRecvReqQueue = NIL_RTREQQUEUE;
    11261126
    11271127    RTSemEventDestroy(pThis->EventRecv);
     
    11721172    pThis->pszBootFile                  = NULL;
    11731173    pThis->pszNextServer                = NULL;
    1174     pThis->pSlirpReqQueue               = NULL;
    1175     pThis->pUrgRecvReqQueue             = NULL;
     1174    pThis->hSlirpReqQueue               = NIL_RTREQQUEUE;
     1175    pThis->hUrgRecvReqQueue             = NIL_RTREQQUEUE;
    11761176    pThis->EventRecv                    = NIL_RTSEMEVENT;
    11771177    pThis->EventUrgRecv                 = NIL_RTSEMEVENT;
     
    13011301             */
    13021302            rc = PDMDrvHlpSSMRegisterLoadDone(pDrvIns, drvNATLoadDone);
    1303             AssertRCReturn(rc, rc);
    1304 
    1305             rc = RTReqCreateQueue(&pThis->pSlirpReqQueue);
    1306             if (RT_FAILURE(rc))
    1307             {
    1308                 LogRel(("NAT: Can't create request queue\n"));
    1309                 return rc;
    1310             }
    1311 
    1312             rc = RTReqCreateQueue(&pThis->pRecvReqQueue);
    1313             if (RT_FAILURE(rc))
    1314             {
    1315                 LogRel(("NAT: Can't create request queue\n"));
    1316                 return rc;
    1317             }
    1318 
    1319             rc = RTReqCreateQueue(&pThis->pUrgRecvReqQueue);
    1320             if (RT_FAILURE(rc))
    1321             {
    1322                 LogRel(("NAT: Can't create request queue\n"));
    1323                 return rc;
    1324             }
     1303            AssertLogRelRCReturn(rc, rc);
     1304
     1305            rc = RTReqQueueCreate(&pThis->hSlirpReqQueue);
     1306            AssertLogRelRCReturn(rc, rc);
     1307
     1308            rc = RTReqQueueCreate(&pThis->hRecvReqQueue);
     1309            AssertLogRelRCReturn(rc, rc);
     1310
     1311            rc = RTReqQueueCreate(&pThis->hUrgRecvReqQueue);
     1312            AssertLogRelRCReturn(rc, rc);
    13251313
    13261314            rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvNATRecv,
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