Changeset 22193 in vbox
- Timestamp:
- Aug 12, 2009 7:23:29 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 50979
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r22192 r22193 62 62 #define VBOX_NAT_DELAY_HACK 63 63 #if 0 64 #define SLIRP_SPLIT_CAN_OUTPUT 1 64 65 #define SLIRP_CAN_SAND_IN_PDM 1 65 66 #define SLIRP_FLUSH_DEV 1 … … 168 169 STAMCOUNTER StatQueuePktSent; /**< counting packet sent via PDM queue */ 169 170 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; 170 176 } DRVNAT; 171 177 /** Pointer the NAT driver instance data. */ … … 533 539 534 540 #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 535 565 536 566 /** … … 541 571 int slirp_can_output(void *pvUser) 542 572 { 543 #ifdef SLIRP_CAN_SAND_IN_PDM 573 #ifdef SLIRP_SPLIT_CAN_OUTPUT 574 # ifdef SLIRP_CAN_SAND_IN_PDM 544 575 int status = 0; 545 576 int rc = 0; … … 554 585 rc = RTSemEventWait(pThis->semStatus, RT_INDEFINITE_WAIT); 555 586 AssertRC(rc); 556 return status ;587 return status & pThis->output_flag; 557 588 } 558 589 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 559 594 #else 560 PDRVNAT pThis = (PDRVNAT)pvUser; 561 return (RT_SUCCESS(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0))? 1 : 0); 595 return 1; 562 596 #endif 563 597 } … … 567 601 #ifdef SLIRP_FLUSH_DEV 568 602 PDRVNAT pThis = (PDRVNAT)pvUser; 569 /*@todo: idealy should be done in other thread */ 570 PDMQueueFlush(pThis->pSendQueue); 603 RTSemEventSignal(pThis->semPDMQueueFlusher); 571 604 #endif 572 605 } … … 632 665 switch (pItem->enmType) { 633 666 case SLIRP_SEND: 667 #ifndef SLIRP_SPLIT_CAN_OUTPUT 668 if (RT_FAILURE(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0))) 669 return false; 670 #endif 634 671 rc = pThis->pPort->pfnReceive(pThis->pPort, pItem->pu8Buf, pItem->cb); 635 672 RTMemFree((void *)pItem->pu8Buf); … … 982 1019 rc = RTSemEventCreate(&pThis->semStatus); 983 1020 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 984 1028 985 1029 #ifndef RT_OS_WINDOWS
Note:
See TracChangeset
for help on using the changeset viewer.