Changeset 28146 in vbox
- Timestamp:
- Apr 9, 2010 2:20:16 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r28143 r28146 675 675 int ms; 676 676 #ifdef RT_OS_WINDOWS 677 DWORD event; 678 HANDLE *phEvents; 677 HANDLE *phEvents = slirp_get_events(pThis->pNATState); 679 678 unsigned int cBreak = 0; 680 679 #else /* RT_OS_WINDOWS */ 681 struct pollfd *polls = NULL;682 680 unsigned int cPollNegRet = 0; 683 681 #endif /* !RT_OS_WINDOWS */ … … 687 685 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING) 688 686 return VINF_SUCCESS; 689 690 #ifdef RT_OS_WINDOWS691 phEvents = slirp_get_events(pThis->pNATState);692 #endif /* RT_OS_WINDOWS */693 687 694 688 /* … … 697 691 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 698 692 { 699 nFDs = -1;700 693 /* 701 694 * To prevent concurent execution of sending/receving threads … … 703 696 #ifndef RT_OS_WINDOWS 704 697 nFDs = slirp_get_nsock(pThis->pNATState); 705 polls = NULL;706 698 /* allocation for all sockets + Management pipe */ 707 polls = (struct pollfd *)RTMemAlloc((1 + nFDs) * sizeof(struct pollfd) + sizeof(uint32_t));699 struct pollfd *polls = (struct pollfd *)RTMemAlloc((1 + nFDs) * sizeof(struct pollfd) + sizeof(uint32_t)); 708 700 if (polls == NULL) 709 701 return VERR_NO_MEMORY; … … 711 703 /* don't pass the managemant pipe */ 712 704 slirp_select_fill(pThis->pNATState, &nFDs, &polls[1]); 713 #if 0714 ms = slirp_get_timeout_ms(pThis->pNATState);715 #else716 ms = 0;717 #endif718 705 719 706 polls[0].fd = pThis->PipeRead; … … 722 709 polls[0].revents = 0; 723 710 724 int cChangedFDs = poll(polls, nFDs + 1, ms ? ms : -1);711 int cChangedFDs = poll(polls, nFDs + 1, slirp_get_timeout_ms(pThis->pNATState)); 725 712 if (cChangedFDs < 0) 726 713 { … … 765 752 RTReqProcess(pThis->pSlirpReqQueue, 0); 766 753 RTMemFree(polls); 754 767 755 #else /* RT_OS_WINDOWS */ 756 nFDs = -1; 768 757 slirp_select_fill(pThis->pNATState, &nFDs); 769 #if 0 770 ms = slirp_get_timeout_ms(pThis->pNATState); 771 #else 772 ms = 0; 773 #endif 774 struct timeval tv = { 0, ms*1000 }; 775 event = WSAWaitForMultipleEvents(nFDs, phEvents, FALSE, ms ? ms : WSA_INFINITE, FALSE); 776 if ( (event < WSA_WAIT_EVENT_0 || event > WSA_WAIT_EVENT_0 + nFDs - 1) 777 && event != WSA_WAIT_TIMEOUT) 758 DWORD dwEvent = WSAWaitForMultipleEvents(nFDs, phEvents, FALSE, 759 slirp_get_timeout_ms(pThis->pNATState), 760 FALSE); 761 if ( (dwEvent < WSA_WAIT_EVENT_0 || dwEvent > WSA_WAIT_EVENT_0 + nFDs - 1) 762 && dwEvent != WSA_WAIT_TIMEOUT) 778 763 { 779 764 int error = WSAGetLastError(); 780 LogRel(("NAT: WSAWaitForMultipleEvents returned %d (error %d)\n", event, error));765 LogRel(("NAT: WSAWaitForMultipleEvents returned %d (error %d)\n", dwEvent, error)); 781 766 RTAssertPanic(); 782 767 } 783 768 784 if ( event == WSA_WAIT_TIMEOUT)769 if (dwEvent == WSA_WAIT_TIMEOUT) 785 770 { 786 771 /* only check for slow/fast timers */ … … 790 775 /* poll the sockets in any case */ 791 776 Log2(("%s: poll\n", __FUNCTION__)); 792 slirp_select_poll(pThis->pNATState, /* fTimeout=*/false, /* fIcmp=*/( event == WSA_WAIT_EVENT_0));777 slirp_select_poll(pThis->pNATState, /* fTimeout=*/false, /* fIcmp=*/(dwEvent == WSA_WAIT_EVENT_0)); 793 778 /* process _all_ outstanding requests but don't wait */ 794 779 RTReqProcess(pThis->pSlirpReqQueue, 0); … … 863 848 void slirp_arm_fast_timer(void *pvUser) 864 849 { 850 #if 0 865 851 PDRVNAT pThis = (PDRVNAT)pvUser; 866 852 AssertPtr(pThis); 867 853 TMTimerSetMillies(pThis->pTmrFast, 2); 854 #endif 868 855 } 869 856 … … 883 870 void slirp_arm_slow_timer(void *pvUser) 884 871 { 872 #if 0 885 873 PDRVNAT pThis = (PDRVNAT)pvUser; 886 874 AssertPtr(pThis); 875 887 876 TMTimerSetMillies(pThis->pTmrSlow, 500); 877 #endif 888 878 } 889 879 -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r28141 r28146 1851 1851 return 500; /* see PR_SLOWHZ */ 1852 1852 } 1853 return 0;1853 return 3600*1000; /* one hour */ 1854 1854 } 1855 1855 -
trunk/src/VBox/NetworkServices/NAT/VBoxNetNAT.cpp
r28025 r28146 51 51 #include <VBox/intnet.h> 52 52 #include <VBox/intnetinline.h> 53 #include <VBox/pdmnetinline.h> 53 54 #include <VBox/vmm.h> 54 55 #include <VBox/version.h> … … 303 304 } 304 305 306 uint8_t abHdrScratch[256]; 305 307 uint32_t const cSegs = PDMNetGsoCalcSegmentCount(pGso, cbFrame - sizeof(*pGso)); 306 308 for (uint32_t iSeg = 0; iSeg < cSegs; iSeg++) … … 308 310 uint32_t cbSegFrame; 309 311 void *pvSegFrame = PDMNetGsoCarveSegmentQD(pGso, (uint8_t *)(pGso + 1), cbFrame, abHdrScratch, 310 &cbSegFrame);312 iSeg, cSegs, &cbSegFrame); 311 313 m = slirp_ext_m_get(g_pNAT->m_pNATState, cbFrame, &pvSlirpFrame, &cbIgnored); 312 314 if (!m) … … 318 320 319 321 rc = RTReqCallEx(m_pReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 320 (PFNRT)SendWorker, 2, m, cbS ubFrame);322 (PFNRT)SendWorker, 2, m, cbSegFrame); 321 323 AssertReleaseRC(rc); 322 324 } … … 463 465 VBoxNetNAT *pThis = (VBoxNetNAT *)pvUser; 464 466 int nFDs = -1; 465 unsigned int ms;466 467 #ifdef RT_OS_WINDOWS 467 DWORD event; 468 HANDLE *phEvents; 469 unsigned int cBreak = 0; 468 HANDLE *pahEvents = slirp_get_events(pThis->m_pNATState); 470 469 #else /* RT_OS_WINDOWS */ 471 struct pollfd *polls = NULL;472 470 unsigned int cPollNegRet = 0; 473 471 #endif /* !RT_OS_WINDOWS */ 474 472 475 473 LogFlow(("drvNATAsyncIoThread: pThis=%p\n", pThis)); 476 477 478 #ifdef RT_OS_WINDOWS479 phEvents = slirp_get_events(pThis->m_pNATState);480 #endif /* RT_OS_WINDOWS */481 474 482 475 /* … … 485 478 for(;;) 486 479 { 487 nFDs = -1;488 489 480 /* 490 481 * To prevent concurent execution of sending/receving threads … … 492 483 #ifndef RT_OS_WINDOWS 493 484 nFDs = slirp_get_nsock(pThis->m_pNATState); 494 polls = NULL;495 485 /* allocation for all sockets + Management pipe */ 496 polls = (struct pollfd *)RTMemAlloc((1 + nFDs) * sizeof(struct pollfd) + sizeof(uint32_t));486 struct pollfd *polls = (struct pollfd *)RTMemAlloc((1 + nFDs) * sizeof(struct pollfd) + sizeof(uint32_t)); 497 487 if (polls == NULL) 498 488 return VERR_NO_MEMORY; … … 500 490 /* don't pass the managemant pipe */ 501 491 slirp_select_fill(pThis->m_pNATState, &nFDs, &polls[1]); 502 ms= slirp_get_timeout_ms(pThis->m_pNATState);492 unsigned int cMsTimeout = slirp_get_timeout_ms(pThis->m_pNATState); 503 493 504 494 polls[0].fd = pThis->m_PipeRead; … … 507 497 polls[0].revents = 0; 508 498 509 int cChangedFDs = poll(polls, nFDs + 1, -1);499 int cChangedFDs = poll(polls, nFDs + 1, cMsTimeout); 510 500 if (cChangedFDs < 0) 511 501 { … … 548 538 RTReqProcess(pThis->m_pReqQueue, 0); 549 539 RTMemFree(polls); 540 550 541 #else /* RT_OS_WINDOWS */ 542 nFDs = -1; 551 543 slirp_select_fill(pThis->m_pNATState, &nFDs); 552 event = WSAWaitForMultipleEvents(nFDs, phEvents, FALSE, WSA_INFINITE, FALSE); 553 if ( (event < WSA_WAIT_EVENT_0 || event > WSA_WAIT_EVENT_0 + nFDs - 1) 554 && event != WSA_WAIT_TIMEOUT) 544 DWORD dwEvent = WSAWaitForMultipleEvents(nFDs, pahEvents, FALSE, 545 slirp_get_timeout_ms(pThis->m_pNATState), 546 FALSE); 547 if ( (dwEvent < WSA_WAIT_EVENT_0 || dwEvent > WSA_WAIT_EVENT_0 + nFDs - 1) 548 && dwEvent != WSA_WAIT_TIMEOUT) 555 549 { 556 550 int error = WSAGetLastError(); 557 LogRel(("NAT: WSAWaitForMultipleEvents returned %d (error %d)\n", event, error));551 LogRel(("NAT: WSAWaitForMultipleEvents returned %d (error %d)\n", dwEvent, error)); 558 552 RTAssertReleasePanic(); 559 553 } 560 554 561 if ( event == WSA_WAIT_TIMEOUT)555 if (dwEvent == WSA_WAIT_TIMEOUT) 562 556 { 563 557 /* only check for slow/fast timers */ … … 567 561 568 562 /* poll the sockets in any case */ 569 slirp_select_poll(pThis->m_pNATState, /* fTimeout=*/false, /* fIcmp=*/( event == WSA_WAIT_EVENT_0));563 slirp_select_poll(pThis->m_pNATState, /* fTimeout=*/false, /* fIcmp=*/(dwEvent == WSA_WAIT_EVENT_0)); 570 564 /* process _all_ outstanding requests but don't wait */ 571 565 RTReqProcess(pThis->m_pReqQueue, 0);
Note:
See TracChangeset
for help on using the changeset viewer.