Changeset 16291 in vbox for trunk/src/VBox
- Timestamp:
- Jan 28, 2009 2:36:37 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42115
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Makefile.kmk
r16245 r16291 647 647 $(if $(VBOX_WITH_SLIRP_MEMORY_CHECK),RTMEM_WRAP_TO_EF_APIS,) \ 648 648 $(if $(VBOX_WITH_DEBUG_NAT_SOCKETS),VBOX_WITH_DEBUG_NAT_SOCKETS,) \ 649 $(if $(VBOX_WITH_MULTI_DNS),VBOX_WITH_MULTI_DNS,) 649 $(if $(VBOX_WITH_MULTI_DNS),VBOX_WITH_MULTI_DNS,) \ 650 $(if $(VBOX_WITH_SLIRP_MT),VBOX_WITH_SLIRP_MT,) 650 651 ifeq ($(KBUILD_TARGET),win) 651 652 $(file)_CFLAGS = -wd4018 -
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r16201 r16291 91 91 /* Send queue */ 92 92 PPDMQUEUE pSendQueue; 93 # ifdef VBOX_WITH_SLIRP_MT 94 PPDMTHREAD pGuestThread; 95 # endif 93 96 # ifndef RT_OS_WINDOWS 94 97 /** The write end of the control pipe. */ … … 437 440 } 438 441 442 #ifdef VBOX_WITH_SLIRP_MT 443 static DECLCALLBACK(int) drvNATAsyncIoGuest(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 444 { 445 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 446 while (1) 447 { 448 } 449 } 450 451 static DECLCALLBACK(int) drvNATAsyncIoGuestWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 452 { 453 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 454 455 return VINF_SUCCESS; 456 } 457 #endif 458 439 459 #endif /* VBOX_WITH_SIMPLIFIED_SLIRP_SYNC */ 440 460 … … 863 883 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pThread, pThis, drvNATAsyncIoThread, drvNATAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT"); 864 884 AssertReleaseRC(rc); 885 886 #ifdef VBOX_WITH_SLIRP_MT 887 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest, drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_EMULATION, "NAT"); 888 AssertReleaseRC(rc); 889 #endif 865 890 #endif 866 891 -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r16254 r16291 8 8 #include <iprt/assert.h> 9 9 10 #ifdef VBOX_WITH_SLIRP_MT 11 # define CONTINUE(label) goto loop_end_ ## label ## _mt 12 /* @todo replace queue parameter with macrodinition */ 13 # define LOOP_LABEL(label, so, sonext) loop_end_ ## label ## _mt: \ 14 SOCKET_UNLOCK(so); \ 15 QSOCKET_LOCK(_X(queue_ ## label ## _label)); \ 16 (so) = (sonext) 17 #else 18 #define CONTINUE(label) continue; 19 # define LOOP_LABEL(label, so, sonext) /* empty*/ 20 #endif 10 21 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 11 22 … … 48 59 # define ICMP_ENGAGE_EVENT(so, fdset) do {} while(0) 49 60 50 # define DO_ENGAGE_EVENT1(so, fdset1, label) \51 do { \52 rc = WSAEventSelect((so)->s, VBOX_SOCKET_EVENT, FD_ALL_EVENTS); \53 if (rc == SOCKET_ERROR) \54 { \55 /* This should not happen */ \56 error = WSAGetLastError(); \57 LogRel(("WSAEventSelector (" #label ") error %d (so=%x, socket=%s, event=%x)\n", \58 error, (so), (so)->s, VBOX_SOCKET_EVENT)); \59 } \60 } while(0); \61 continue61 # define DO_ENGAGE_EVENT1(so, fdset1, label) \ 62 do { \ 63 rc = WSAEventSelect((so)->s, VBOX_SOCKET_EVENT, FD_ALL_EVENTS); \ 64 if (rc == SOCKET_ERROR) \ 65 { \ 66 /* This should not happen */ \ 67 error = WSAGetLastError(); \ 68 LogRel(("WSAEventSelector (" #label ") error %d (so=%x, socket=%s, event=%x)\n", \ 69 error, (so), (so)->s, VBOX_SOCKET_EVENT)); \ 70 } \ 71 } while(0); \ 72 CONTINUE(label) 62 73 63 74 # define DO_ENGAGE_EVENT2(so, fdset1, fdset2, label) \ … … 70 81 (error) = WSAGetLastError(); \ 71 82 LogRel(("WSAEnumNetworkEvents " #label " error %d\n", (error))); \ 72 continue;\83 CONTINUE(label); \ 73 84 } 74 85 … … 93 104 94 105 #define TCP_ENGAGE_EVENT1(so, fdset) \ 95 DO_ENGAGE_EVENT1((so), (fdset), TCP)106 DO_ENGAGE_EVENT1((so), (fdset), tcp) 96 107 97 108 #define TCP_ENGAGE_EVENT2(so, fdset1, fdset2) \ 98 DO_ENGAGE_EVENT2((so), (fdset1), (fdset2), TCP)109 DO_ENGAGE_EVENT2((so), (fdset1), (fdset2), tcp) 99 110 100 111 #define UDP_ENGAGE_EVENT(so, fdset) \ 101 DO_ENGAGE_EVENT1((so), (fdset), UDP)112 DO_ENGAGE_EVENT1((so), (fdset), udp) 102 113 103 114 #define POLL_TCP_EVENTS(rc, error, so, events) \ 104 DO_POLL_EVENTS((rc), (error), (so), (events), TCP)115 DO_POLL_EVENTS((rc), (error), (so), (events), tcp) 105 116 106 117 #define POLL_UDP_EVENTS(rc, error, so, events) \ 107 DO_POLL_EVENTS((rc), (error), (so), (events), UDP)118 DO_POLL_EVENTS((rc), (error), (so), (events), udp) 108 119 109 120 #define CHECK_FD_SET(so, events, set) \ … … 582 593 STAM_COUNTER_RESET(&pData->StatTCPHot); 583 594 584 for (so = tcb.so_next; so != &tcb; so = so_next) 585 { 586 so_next = so->so_next; 587 595 QSOCKET_FOREACH(so, so_next, tcp) 596 /* { */ 588 597 STAM_COUNTER_INC(&pData->StatTCP); 589 598 … … 599 608 */ 600 609 if (so->so_state & SS_NOFDREF || so->s == -1) 601 continue;610 CONTINUE(tcp); 602 611 603 612 /* … … 608 617 STAM_COUNTER_INC(&pData->StatTCPHot); 609 618 TCP_ENGAGE_EVENT1(so, readfds); 610 continue;619 CONTINUE(tcp); 611 620 } 612 621 … … 640 649 TCP_ENGAGE_EVENT2(so, readfds, xfds); 641 650 } 651 LOOP_LABEL(tcp, so, so_next); 642 652 } 643 653 … … 648 658 STAM_COUNTER_RESET(&pData->StatUDPHot); 649 659 650 for (so = udb.so_next; so != &udb; so = so_next)651 {660 QSOCKET_FOREACH(so, so_next, udp) 661 /* { */ 652 662 so_next = so->so_next; 653 663 … … 662 672 { 663 673 udp_detach(pData, so); 664 continue;674 CONTINUE(udp); 665 675 } 666 676 else … … 683 693 UDP_ENGAGE_EVENT(so, readfds); 684 694 } 695 LOOP_LABEL(udp, so, so_next); 685 696 } 686 697 … … 768 779 */ 769 780 if (so->so_state & SS_NOFDREF || so->s == -1) 770 continue;781 CONTINUE(tcp); 771 782 772 783 POLL_TCP_EVENTS(rc, error, so, &NetworkEvents); … … 801 812 if (!(NetworkEvents.lNetworkEvents & FD_CLOSE)) 802 813 #endif 803 continue;814 CONTINUE(tcp); 804 815 } 805 816 … … 859 870 || errno == EINPROGRESS 860 871 || errno == ENOTCONN) 861 continue;872 CONTINUE(tcp); 862 873 863 874 /* else failed */ … … 899 910 || errno == ENOTCONN) 900 911 { 901 continue; /* Still connecting, continue */912 CONTINUE(tcp); /* Still connecting, continue */ 902 913 } 903 914 … … 918 929 || errno == ENOTCONN) 919 930 { 920 continue;931 CONTINUE(tcp); 921 932 } 922 933 /* else failed */ … … 930 941 } /* SS_ISFCONNECTING */ 931 942 #endif 943 LOOP_LABEL(tcp, so, so_next); 932 944 } 933 945 … … 949 961 sorecvfrom(pData, so); 950 962 } 951 } 952 953 } 954 963 LOOP_LABEL(udp, so, so_next); 964 } 965 966 } 967 968 #ifndef VBOX_WITH_SLIRP_MT 955 969 /* 956 970 * See if we can start outputting … … 958 972 if (if_queued && link_up) 959 973 if_start(pData); 974 #endif 960 975 961 976 STAM_PROFILE_STOP(&pData->StatPoll, a); -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r16249 r16291 115 115 /* Stuff from tcp_input.c */ 116 116 struct socket tcb; 117 #ifdef VBOX_WITH_SLIRP_MT 118 RTSEMMUTEX tcb_mutex; 119 #endif 117 120 struct socket *tcp_last_so; 118 121 tcp_seq tcp_iss; … … 130 133 struct udpstat_t udpstat; 131 134 struct socket udb; 135 #ifdef VBOX_WITH_SLIRP_MT 136 RTSEMMUTEX udb_mutex; 137 #endif 132 138 struct socket *udp_last_so; 133 139 struct socket icmp_socket; … … 267 273 #endif 268 274 275 #define queue_tcp_label tcb 276 #define queue_udp_label udb 277 #define __X(x) x 278 #define _X(x) __X(x) 279 280 #ifdef VBOX_WITH_SLIRP_MT 281 #define QSOCKET_LOCK(queue) \ 282 do { \ 283 int rc = RTSemMutexRequest(_X(queue) ## _mutex, RT_INDEFINITE_WAIT); \ 284 AssertReleaseRC(rc); \ 285 } while (0) 286 #define QSOCKET_UNLOCK(queue) \ 287 do { \ 288 int rc = RTSemMutexRelease(_X(queue) ## _mutex); \ 289 AssertReleaseRC(rc); \ 290 } while (0) 291 #define QSOCKET_LOCK_CREATE(queue) \ 292 do { \ 293 int rc = RTSemMutexCreate(&pData->queue ## _mutex); \ 294 AssertReleaseRC(rc); \ 295 } while (0) 296 #define QSOCKET_LOCK_DESTROY(queue) \ 297 do { \ 298 int rc = RTSemMutexDestroy(pData->queue ## _mutex); \ 299 AssertReleaseRC(rc); \ 300 } while (0) 301 302 # define QSOCKET_FOREACH(so, sonext, label) \ 303 QSOCKET_LOCK(__X(queue_## label ## _label)); \ 304 (so) = (_X(queue_ ## label ## _label)).so_next; \ 305 SOCKET_LOCK((so)); \ 306 for(;;) \ 307 { \ 308 if ((so) == &(_X(queue_## label ## _label))) \ 309 { \ 310 QSOCKET_UNLOCK(__X(queue_## label ##_label)); \ 311 break; \ 312 } \ 313 if ((so)->so_next != &(_X(queue_## label ## _label))) \ 314 { \ 315 SOCKET_LOCK((so)->so_next); \ 316 } \ 317 (sonext) = (so)->so_next; \ 318 QSOCKET_UNLOCK(__X(queue_## label ##_label)); 319 #else 320 #define QSOCKET_LOCK(queue) do {} while (0) 321 #define QSOCKET_UNLOCK(queue) do {} while (0) 322 #define QSOCKET_LOCK_CREATE(queue) do {} while (0) 323 #define QSOCKET_LOCK_DESTROY(queue) do {} while (0) 324 # define QSOCKET_FOREACH(so, sonext, label) \ 325 for ((so) = __X(queue_ ## label ## _label).so_next; so != &(__X(queue_ ## label ## _label)); (so) = (sonext)) \ 326 { \ 327 (sonext) = (so)->so_next; 328 #endif 329 269 330 #endif /* !_slirp_state_h_ */ -
trunk/src/VBox/Devices/Network/slirp/socket.c
r16226 r16291 72 72 /* 73 73 * remque and free a socket, clobber cache 74 * VBOX_WITH_SLIRP_MT: before sofree queue should be locked, because 75 * in sofree we don't know from which queue item beeing removed. 74 76 */ 75 77 void … … 87 89 if(so->so_next && so->so_prev) 88 90 remque(pData, so); /* crashes if so is not in a queue */ 91 92 SOCKET_UNLOCK(so); 93 SOCKET_LOCK_DESTROY(so); 89 94 90 95 RTMemFree(so); … … 644 649 return NULL; 645 650 } 651 652 SOCKET_LOCK_CREATE(so); 653 SOCKET_LOCK(so); 654 QSOCKET_LOCK(tcb); 646 655 insque(pData, so,&tcb); 656 QSOCKET_UNLOCK(tcb); 647 657 648 658 /* … … 674 684 int tmperrno = errno; /* Don't clobber the real reason we failed */ 675 685 close(s); 686 QSOCKET_LOCK(tcb); 676 687 sofree(pData, so); 688 QSOCKET_UNLOCK(tcb); 677 689 /* Restore the real errno */ 678 690 errno = tmperrno; -
trunk/src/VBox/Devices/Network/slirp/socket.h
r15636 r16291 10 10 #ifndef _SLIRP_SOCKET_H_ 11 11 #define _SLIRP_SOCKET_H_ 12 #ifdef VBOX_WITH_SLIRP_MT 13 #include <iprt/semaphore.h> 14 #endif 12 15 13 16 #define SO_EXPIRE 240000 … … 64 67 struct sbuf so_rcv; /* Receive buffer */ 65 68 struct sbuf so_snd; /* Send buffer */ 69 #ifdef VBOX_WITH_SLIRP_MT 70 RTSEMMUTEX so_mutex; 71 #endif 66 72 }; 67 73 68 74 #ifdef VBOX_WITH_SLIRP_MT 75 # define SOCKET_LOCK(so) \ 76 do { \ 77 int rc = RTSemMutexRequest((so)->so_mutex, RT_INDEFINITE_WAIT); \ 78 AssertReleaseRC(rc); \ 79 } while (0) 80 # define SOCKET_UNLOCK(so) \ 81 do { \ 82 int rc = RTSemMutexRelease((so)->so_mutex); \ 83 AssertReleaseRC(rc); \ 84 } while (0) 85 # define SOCKET_LOCK_CREATE(so) \ 86 do { \ 87 int rc = RTSemMutexCreate(&(so)->so_mutex); \ 88 AssertReleaseRC(rc); \ 89 } while (0) 90 # define SOCKET_LOCK_DESTROY(so) \ 91 do { \ 92 int rc = RTSemMutexDestroy((so)->so_mutex); \ 93 AssertReleaseRC(rc); \ 94 } while (0) 95 #else 96 # define SOCKET_LOCK(so) do {} while (0) 97 # define SOCKET_UNLOCK(so) do {} while (0) 98 # define SOCKET_LOCK_CREATE(so) do {} while (0) 99 # define SOCKET_LOCK_DESTROY(so) do {} while (0) 100 #endif 69 101 /* 70 102 * Socket state bits. (peer means the host on the Internet, -
trunk/src/VBox/Devices/Network/slirp/tcp_input.c
r16071 r16291 433 433 goto dropwithreset; 434 434 } 435 435 436 SOCKET_LOCK(so); 436 437 sbreserve(&so->so_snd, tcp_sndspace); 437 438 sbreserve(&so->so_rcv, tcp_rcvspace); -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r16226 r16291 539 539 return -1; 540 540 541 SOCKET_LOCK_CREATE(so); 542 QSOCKET_LOCK(tcb); 541 543 insque(pData, so, &tcb); 544 QSOCKET_UNLOCK(tcb); 542 545 return 0; 543 546 } -
trunk/src/VBox/Devices/Network/slirp/udp.c
r16213 r16291 384 384 /* enable broadcast for later use */ 385 385 setsockopt(so->s, SOL_SOCKET, SO_BROADCAST, (const char *)&opt, sizeof(opt)); 386 SOCKET_LOCK_CREATE(so); 387 QSOCKET_LOCK(udb); 386 388 insque(pData, so,&udb); 389 QSOCKET_UNLOCK(udb); 387 390 status = getsockname(so->s, &sa_addr, &socklen); 388 391 Assert(status == 0 && sa_addr.sa_family == AF_INET);
Note:
See TracChangeset
for help on using the changeset viewer.