Changeset 16653 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Feb 11, 2009 8:56:10 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42639
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r16613 r16653 43 43 # ifndef RT_OS_WINDOWS 44 44 # include <unistd.h> 45 # include <fcntl.h> 45 46 # include <poll.h> 46 47 # endif … … 350 351 unsigned int cBreak = 0; 351 352 # else 352 struct pollfd *polls ;353 struct pollfd *polls = NULL; 353 354 # endif 354 355 … … 374 375 # ifndef RT_OS_WINDOWS 375 376 nFDs = slirp_get_nsock(pThis->pNATState); 376 polls = (struct pollfd *)RTMemAllocZ((2 + nFDs) * sizeof(struct pollfd)); /* allocation for all sockets + ICMP and Management pipe*/ 377 polls = NULL; 378 polls = (struct pollfd *)RTMemAlloc((1 + nFDs) * sizeof(struct pollfd) + sizeof(uint32_t)); /* allocation for all sockets + Management pipe*/ 377 379 if (polls == NULL) 378 380 { 379 381 LogRel(("Can't allocate memory for polling\n")); 380 AssertRelease(polls);382 return VERR_NO_MEMORY; 381 383 } 382 384 … … 386 388 polls[0].fd = pThis->PipeRead; 387 389 polls[0].events = POLLRDNORM|POLLPRI|POLLRDBAND; /* POLLRDBAND usually doesn't used on Linux but seems used on Solaris */ 388 int cChangedFDs = poll(polls, nFDs + 2, ms ? ms : -1); 390 polls[0].revents = 0; 391 392 int cChangedFDs = poll(polls, nFDs + 1, ms ? ms : -1); 393 AssertRelease(cChangedFDs >= 0); 389 394 if (cChangedFDs >= 0) 390 395 { 391 slirp_select_poll(pThis->pNATState, &polls[1], nFDs + 1);396 slirp_select_poll(pThis->pNATState, &polls[1], nFDs); 392 397 if (polls[0].revents & (POLLRDNORM|POLLPRI|POLLRDBAND)) 393 398 { -
trunk/src/VBox/Devices/Network/slirp/if.c
r15890 r16653 186 186 { 187 187 /* check if we can really output */ 188 if (!slirp_can_output(pData->pvUser)) 188 if (!slirp_can_output(pData->pvUser)) 189 189 { 190 190 Log(("if_start: can't send\n")); -
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r16614 r16653 101 101 } 102 102 fd_nonblock(pData->icmp_socket.s); 103 NSOCK_INC(); 103 104 #else /* RT_OS_WINDOWS */ 104 105 pData->hmIcmpLibrary = LoadLibrary("Iphlpapi.dll"); -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r16612 r16653 33 33 # define DO_UNIX_CHECK_FD_SET(so, events, fdset ) 0 /*specific for Unix API */ 34 34 # else /* !VBOX_WITH_SIMPLIFIED_SLIRP_SYNC */ 35 # define DO_ENGAGE_EVENT1(so, fdset, label) \ 36 do { \ 37 polls[poll_index].fd = (so)->s; \ 38 (so)->so_poll_index = poll_index; \ 39 polls[poll_index].events = N_(fdset ## _poll); \ 40 poll_index++; \ 35 # define DO_ENGAGE_EVENT1(so, fdset, label) \ 36 do { \ 37 AssertRelease(poll_index < (nfds)); \ 38 if( so->so_poll_index != -1 \ 39 && so->s == polls[so->so_poll_index].fd) { \ 40 polls[poll_index].events |= N_(fdset ## _poll); \ 41 break; /* out of this loop */ \ 42 } \ 43 AssertRelease(poll_index >= 0 && poll_index < (nfds)); \ 44 polls[poll_index].fd = (so)->s; \ 45 (so)->so_poll_index = poll_index; \ 46 polls[poll_index].events = N_(fdset ## _poll); \ 47 polls[poll_index].revents = 0; \ 48 poll_index++; \ 41 49 } while(0) 42 50 … … 44 52 # define DO_ENGAGE_EVENT2(so, fdset1, fdset2, label) \ 45 53 do { \ 54 AssertRelease(poll_index < (nfds)); \ 55 if( so->so_poll_index != -1 \ 56 && so->s == polls[so->so_poll_index].fd) { \ 57 polls[poll_index].events |= N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \ 58 break; /* out of this loop */ \ 59 } \ 46 60 polls[poll_index].fd = (so)->s; \ 47 61 (so)->so_poll_index = poll_index; \ … … 689 703 QSOCKET_FOREACH(so, so_next, tcp) 690 704 /* { */ 705 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && !defined(RT_OS_WINDOWS) 706 so->so_poll_index = -1; 707 #endif 691 708 STAM_COUNTER_INC(&pData->StatTCP); 692 709 … … 758 775 759 776 STAM_COUNTER_INC(&pData->StatUDP); 777 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && !defined(RT_OS_WINDOWS) 778 so->so_poll_index = -1; 779 #endif 760 780 761 781 /* … … 801 821 *pnfds = VBOX_EVENT_COUNT; 802 822 # else /* RT_OS_WINDOWS */ 823 AssertRelease(poll_index <= *pnfds); 803 824 *pnfds = poll_index; 804 825 # endif /* !RT_OS_WINDOWS */ … … 924 945 925 946 LOG_NAT_SOCK(so, TCP, &NetworkEvents, readfds, writefds, xfds); 947 926 948 927 949 /* … … 1089 1111 so->so_state = SS_NOFDREF; 1090 1112 TCP_INPUT(pData, (struct mbuf *)NULL, sizeof(struct ip), so); 1113 CONTINUE(tcp); 1091 1114 } 1092 1115 /* Here should be other error handlings */ 1116 AssertRelease(!"shouldn't be here!!!"); 1093 1117 } 1094 1118 #endif -
trunk/src/VBox/Devices/Network/slirp/socket.c
r16571 r16653 66 66 so->so_state = SS_NOFDREF; 67 67 so->s = -1; 68 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && !defined(RT_OS_WINDOWS) 69 so->so_poll_index = -1; 70 #endif 68 71 } 69 72 return so; … … 89 92 #ifndef VBOX_WITH_SLIRP_MT 90 93 if(so->so_next && so->so_prev) 94 { 91 95 remque(pData, so); /* crashes if so is not in a queue */ 92 96 NSOCK_DEC(); 93 so->so_state = SS_NOFDREF; /* for debugging purposes */97 } 94 98 95 99 RTMemFree(so);
Note:
See TracChangeset
for help on using the changeset viewer.