Changeset 16448 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Feb 2, 2009 3:52:54 AM (16 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r16444 r16448 152 152 PRTREQ pReq = NULL; 153 153 int rc; 154 const void *buf; 154 155 /* don't queue new requests when the NAT thread is about to stop */ 155 156 if (pThis->pThread->enmState != PDMTHREADSTATE_RUNNING) 156 157 return VINF_SUCCESS; 157 # ifndef VBOX_WITH_SLIRP_MT158 # ifndef VBOX_WITH_SLIRP_MT 158 159 rc = RTReqAlloc(pThis->pReqQueue, &pReq, RTREQTYPE_INTERNAL); 159 #else 160 buf = pvBuf; 161 # else 162 buf = (const void *)RTMemAlloc(cb); 163 memcpy((void *)buf, pvBuf, cb); 160 164 rc = RTReqAlloc((PRTREQQUEUE)slirp_get_queue(pThis->pNATState), &pReq, RTREQTYPE_INTERNAL); 161 # endif165 # endif 162 166 AssertReleaseRC(rc); 163 167 pReq->u.Internal.pfn = (PFNRT)drvNATSendWorker; 164 168 pReq->u.Internal.cArgs = 3; 165 169 pReq->u.Internal.aArgs[0] = (uintptr_t)pThis; 166 pReq->u.Internal.aArgs[1] = (uintptr_t) pvBuf;170 pReq->u.Internal.aArgs[1] = (uintptr_t)buf; 167 171 pReq->u.Internal.aArgs[2] = (uintptr_t)cb; 172 # ifndef VBOX_WITH_SLIRP_MT 168 173 pReq->fFlags = RTREQFLAGS_VOID; 174 # else 175 pReq->fFlags = RTREQFLAGS_VOID|RTREQFLAGS_NO_WAIT; 176 # endif 169 177 170 178 rc = RTReqQueue(pReq, 0); /* don't wait, we have to wakeup the NAT thread fist */ 179 #ifndef VBOX_WITH_SLIRP_MT 171 180 if (RT_LIKELY(rc == VERR_TIMEOUT)) 172 181 { … … 186 195 AssertReleaseRC(rc); 187 196 RTReqFree(pReq); 197 #else 198 # ifndef RT_OS_WINDOWS 199 /* kick select() */ 200 rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL); 201 AssertRC(rc); 202 # else 203 /* kick WSAWaitForMultipleEvents */ 204 rc = WSASetEvent(pThis->hWakeupEvent); 205 AssertRelease(rc == TRUE); 206 # endif 207 AssertReleaseRC(rc); 208 #endif 188 209 189 210 #else /* !VBOX_WITH_SIMPLIFIED_SLIRP_SYNC */ … … 896 917 897 918 #ifdef VBOX_WITH_SLIRP_MT 898 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest, drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_ EMULATION, "NAT");919 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest, drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATGUEST"); 899 920 AssertReleaseRC(rc); 900 921 #endif -
trunk/src/VBox/Devices/Network/slirp/debug.c
r16445 r16448 253 253 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "socket is null"); 254 254 if (so->so_state == SS_NOFDREF || so->s == -1) 255 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "socket SS_NODREF");255 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "socket(%d) SS_NODREF",so->s); 256 256 status = getsockname(so->s, &addr, &socklen); 257 257 258 Assert(status == 0 && addr.sa_family == AF_INET); 258 if(status != 0 || addr.sa_family != AF_INET) 259 { 260 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "socket(%d) is invalid(probably closed)",so->s); 261 } 259 262 260 263 ip = ntohl(so->so_faddr.s_addr); -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r16445 r16448 622 622 * See if we need a tcp_fasttimo 623 623 */ 624 if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) 624 if ( time_fasttimo == 0 625 && so->so_tcpcb != NULL 626 && so->so_tcpcb->t_flags & TF_DELACK) 625 627 time_fasttimo = curtime; /* Flag when we want a fasttimo */ 626 628 … … 692 694 if (so->so_expire <= curtime) 693 695 { 694 QSOCKET_LOCK(udb);695 696 #ifdef VBOX_WITH_SLIRP_MT 696 /*we can determinate the next item after udb_detach*/ 697 if (so->so_next != &tcb) 698 { 699 SOCKET_LOCK(so->so_next); 700 so_next = so->so_next; 701 } 702 #endif 703 QSOCKET_UNLOCK(udb); 704 udp_detach(pData, so); 697 /* we need so_next for continue our cycle*/ 698 so_next = so->so_next; 699 #endif 700 UDP_DETACH(pData, so, so_next); 705 701 CONTINUE_NO_UNLOCK(udp); 706 702 } -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r16445 r16448 382 382 pReq->u.Internal.aArgs[2] = (uintptr_t)(size); \ 383 383 pReq->u.Internal.aArgs[3] = (uintptr_t)(so); \ 384 pReq->fFlags = RTREQFLAGS_VOID ;\384 pReq->fFlags = RTREQFLAGS_VOID|RTREQFLAGS_NO_WAIT; \ 385 385 rc = RTReqQueue(pReq, 0); \ 386 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 387 { \ 388 SOCKET_UNLOCK(so); \ 389 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 390 AssertReleaseRC(rc); \ 391 SOCKET_LOCK(so); \ 392 RTReqFree(pReq); \ 393 } \ 394 else \ 395 AssertReleaseRC(rc); \ 386 AssertReleaseRC(rc); \ 396 387 } while(0) 397 388 … … 488 479 AssertReleaseRC(rc); \ 489 480 SOCKET_LOCK(so); \ 481 RTReqFree(pReq); \ 482 } \ 483 else \ 484 AssertReleaseRC(rc); \ 485 } while(0) 486 487 #define DO_UDP_DETACH(data, so, so_next) \ 488 do { \ 489 PRTREQ pReq = NULL; \ 490 int rc; \ 491 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 492 AssertReleaseRC(rc); \ 493 pReq->u.Internal.pfn = (PFNRT)udp_detach; \ 494 pReq->u.Internal.cArgs = 2; \ 495 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 496 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 497 pReq->fFlags = RTREQFLAGS_VOID; \ 498 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 499 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 500 { \ 501 SOCKET_UNLOCK(so); \ 502 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 503 AssertReleaseRC(rc); \ 504 if ((so_next) != &udb) SOCKET_LOCK((so_next)); \ 490 505 RTReqFree(pReq); \ 491 506 } \ … … 536 551 (so) = solookup(&__X(queue_ ## label ## _label), (src), (sport), (dst), (dport)); \ 537 552 } while (0) 553 #define DO_UDP_DETACH(data, so, ignored) udp_detach((data), (so)) 538 554 #endif 539 555 … … 544 560 #define SOWRITE(ret, data, so) DO_SOWRITE((ret), (data), (so)) 545 561 #define SORECVFROM(data, so) DO_SORECFROM((data), (so)) 562 #define UDP_DETACH(data, so, so_next) DO_UDP_DETACH((data), (so), (so_next)) 546 563 #endif /* !_slirp_state_h_ */ -
trunk/src/VBox/Devices/Network/slirp/socket.c
r16445 r16448 88 88 m_free(pData, so->so_m); 89 89 if(so->so_next && so->so_prev) 90 {91 if ( so->so_prev != NULL92 && so->so_prev != &udb93 && so->so_prev != &tcb)94 {95 SOCKET_LOCK(so->so_prev);96 so_prev = so->so_prev;97 }98 90 remque(pData, so); /* crashes if so is not in a queue */ 99 if (so_prev != NULL)100 SOCKET_UNLOCK(so_prev);101 }102 91 so->so_state = SS_NOFDREF; /* for debugging purposes */ 103 92 SOCKET_UNLOCK(so); … … 105 94 106 95 RTMemFree(so); 107 so = NULL;108 96 } 109 97 -
trunk/src/VBox/Devices/Network/slirp/tcp_input.c
r16445 r16448 1654 1654 m_free(pData, m); 1655 1655 1656 SOCKET_UNLOCK(so); 1656 #ifdef VBOX_WITH_SLIRP_MT 1657 /*socket should be killed atm*/ 1658 AssertRelease(!RTCritSectIsInitialized(&so->so_mutex)); 1659 #endif 1657 1660 return; 1658 1661 } -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r16291 r16448 263 263 struct socket *so = tp->t_socket; 264 264 register struct mbuf *m; 265 struct socket *so_next, *so_prev; 265 266 266 267 struct tseg_qent *te = NULL; 267 268 DEBUG_CALL("tcp_close"); 268 269 DEBUG_ARG("tp = %lx", (long )tp); 270 so_next = so_prev = NULL; 269 271 /*XXX: freeing the reassembly queue */ 270 272 while (!LIST_EMPTY(&tp->t_segq)) … … 285 287 sbfree(&so->so_rcv); 286 288 sbfree(&so->so_snd); 289 QSOCKET_LOCK(tcb); 290 if ( so->so_next != &tcb 291 && so->so_next != NULL) 292 { 293 SOCKET_LOCK(so->so_next); 294 so_next = so->so_next; 295 } 296 if ( so->so_prev != &tcb 297 && so->so_prev != NULL) 298 { 299 SOCKET_LOCK(so->so_prev); 300 so_prev = so->so_prev; 301 } 302 QSOCKET_UNLOCK(tcb); 287 303 sofree(pData, so); 304 if (so_next != NULL) SOCKET_UNLOCK(so_next); 305 if (so_prev != NULL) SOCKET_UNLOCK(so_prev); 288 306 tcpstat.tcps_closed++; 289 307 return ((struct tcpcb *)0); -
trunk/src/VBox/Devices/Network/slirp/udp.c
r16443 r16448 400 400 udp_detach(PNATState pData, struct socket *so) 401 401 { 402 struct socket *so_next, *so_prev; 403 so_next = so_prev = NULL; 402 404 if (so != &pData->icmp_socket) 403 405 { 406 QSOCKET_LOCK(udb); 407 SOCKET_LOCK(so); 408 if ( so->so_next != &udb 409 && so->so_next != NULL) 410 { 411 SOCKET_LOCK(so->so_next); 412 so_next = so->so_next; 413 } 414 if ( so->so_prev != &udb 415 && so->so_prev != NULL) 416 { 417 SOCKET_LOCK(so->so_prev); 418 so_prev = so->so_prev; 419 } 420 QSOCKET_UNLOCK(udb); 404 421 closesocket(so->s); 405 QSOCKET_LOCK(udb);406 422 sofree(pData, so); 407 QSOCKET_UNLOCK(udb); 423 if(so_prev != NULL) 424 SOCKET_UNLOCK(so_prev); 425 if(so_next != NULL) 426 SOCKET_UNLOCK(so_next); 408 427 } 409 428 }
Note:
See TracChangeset
for help on using the changeset viewer.