Changeset 22160 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Aug 11, 2009 11:55:43 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r22020 r22160 148 148 /* Send queue */ 149 149 PPDMQUEUE pSendQueue; 150 151 RTSEMEVENT semStatus; 150 152 #ifdef VBOX_WITH_SLIRP_MT 151 153 PPDMTHREAD pGuestThread; … … 169 171 * NAT queue item. 170 172 */ 173 typedef enum SLIRP_EVENT {SLIRP_CHECK, SLIRP_SEND} SLIRP_EVENT; 171 174 typedef struct DRVNATQUEUITEM 172 175 { 173 176 /** The core part owned by the queue manager. */ 174 177 PDMQUEUEITEMCORE Core; 178 SLIRP_EVENT enmType; 179 int *pStatus; 175 180 /** The buffer for output to guest. */ 176 181 const uint8_t *pu8Buf; … … 275 280 /* nothing to do */ 276 281 } 277 278 282 279 283 /** … … 533 537 int slirp_can_output(void *pvUser) 534 538 { 539 int status = 0; 540 int rc = 0; 535 541 PDRVNAT pThis = (PDRVNAT)pvUser; 536 542 537 Assert(pThis); 538 return 1; 543 PDRVNATQUEUITEM pItem = (PDRVNATQUEUITEM)PDMQueueAlloc(pThis->pSendQueue); 544 if (pItem) 545 { 546 pItem->enmType = SLIRP_CHECK; 547 pItem->pStatus = &status; 548 PDMQueueInsert(pThis->pSendQueue, &pItem->Core); 549 rc = RTSemEventWait(pThis->semStatus, RT_INDEFINITE_WAIT); 550 AssertRC(rc); 551 return status; 552 } 553 return 0; 539 554 } 540 555 … … 560 575 if (pItem) 561 576 { 577 pItem->enmType = SLIRP_SEND; 562 578 pItem->pu8Buf = pu8Buf; 563 579 pItem->cb = cb; … … 591 607 static DECLCALLBACK(bool) drvNATQueueConsumer(PPDMDRVINS pDrvIns, PPDMQUEUEITEMCORE pItemCore) 592 608 { 609 int rc; 593 610 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 594 611 PDRVNATQUEUITEM pItem = (PDRVNATQUEUITEM)pItemCore; … … 596 613 Log(("drvNATQueueConsumer(pItem:%p, pu8Buf:%p, cb:%d)\n", pItem, pItem->pu8Buf, pItem->cb)); 597 614 Log2(("drvNATQueueConsumer: pu8Buf:\n%.Rhxd\n", pItem->pu8Buf)); 598 int rc = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0); 599 if (RT_FAILURE(rc)) 600 return false; 601 rc = pThis->pPort->pfnReceive(pThis->pPort, pItem->pu8Buf, pItem->cb); 615 switch (pItem->enmType) { 616 case SLIRP_SEND: 617 rc = pThis->pPort->pfnReceive(pThis->pPort, pItem->pu8Buf, pItem->cb); 618 RTMemFree((void *)pItem->pu8Buf); 619 break; 620 case SLIRP_CHECK: 621 622 *pItem->pStatus = (RT_SUCCESS(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0))? 1 : 0); 623 rc = RTSemEventSignal(pThis->semStatus); 624 AssertRC(rc); 625 break; 626 } 627 return true; 602 628 603 629 #if 0 … … 613 639 /*Copy buffer again, till seeking good way of syncronization with slirp mbuf management code*/ 614 640 AssertRelease(pItem->mbuf == NULL); 615 RTMemFree((void *)pItem->pu8Buf);616 641 #endif 617 642 return RT_SUCCESS(rc); … … 937 962 return rc; 938 963 } 964 965 rc = RTSemEventCreate(&pThis->semStatus); 966 AssertRC(rc); 939 967 940 968 #ifndef RT_OS_WINDOWS
Note:
See TracChangeset
for help on using the changeset viewer.