- Timestamp:
- Aug 12, 2009 11:10:15 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r22193 r22201 62 62 #define VBOX_NAT_DELAY_HACK 63 63 #if 0 64 #define SLIRP_CAN_SAND_IN_PDM 1 64 65 #define SLIRP_SPLIT_CAN_OUTPUT 1 65 #define SLIRP_CAN_SAND_IN_PDM 166 66 #define SLIRP_FLUSH_DEV 1 67 67 #endif … … 177 177 /** Pointer the NAT driver instance data. */ 178 178 typedef DRVNAT *PDRVNAT; 179 180 #ifdef SLIRP_FLUSH_DEV 181 static 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 222 static 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 179 230 180 231 /** … … 487 538 # endif 488 539 #endif /* RT_OS_WINDOWS */ 540 drvNATPDMQueueFlusherWakeup(pThis->pDrvIns, pThis->pPDMQueueFlusher); 489 541 } 490 542 … … 539 591 540 592 #endif /* VBOX_WITH_SLIRP_MT */ 541 #ifdef SLIRP_FLUSH_DEV542 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 #endif565 593 566 594 /** … … 590 618 # else 591 619 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; 593 622 # endif 594 623 #else … … 600 629 { 601 630 #ifdef SLIRP_FLUSH_DEV 631 #if 0 602 632 PDRVNAT pThis = (PDRVNAT)pvUser; 603 RTSemEventSignal(pThis->semPDMQueueFlusher); 633 drvNATPDMQueueFlusherWakeup(pThis->pDrvIns, pThis->pPDMQueueFlusher); 634 #endif 604 635 #endif 605 636 } … … 1019 1050 rc = RTSemEventCreate(&pThis->semStatus); 1020 1051 AssertRC(rc); 1021 pThis->output_flag = 1;1052 pThis->output_flag = 0; 1022 1053 #ifdef SLIRP_FLUSH_DEV 1023 1054 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pPDMQueueFlusher, pThis, drvNATPDMQueueFlusher,
Note:
See TracChangeset
for help on using the changeset viewer.