Changeset 16443 in vbox for trunk/src/VBox/Devices/Network/slirp/socket.c
- Timestamp:
- Jan 31, 2009 7:16:03 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/socket.c
r16293 r16443 60 60 struct socket *so; 61 61 62 so = (struct socket *)RTMemAlloc (sizeof(struct socket));62 so = (struct socket *)RTMemAllocZ(sizeof(struct socket)); 63 63 if(so) 64 64 { … … 89 89 if(so->so_next && so->so_prev) 90 90 remque(pData, so); /* crashes if so is not in a queue */ 91 91 so->so_state = SS_NOFDREF; /* for debugging purposes */ 92 92 SOCKET_UNLOCK(so); 93 93 SOCKET_LOCK_DESTROY(so); 94 94 95 95 RTMemFree(so); 96 } 96 so = NULL; 97 } 98 99 #ifdef VBOX_WITH_SLIRP_MT 100 void 101 soread_queue(PNATState pData, struct socket *so, int fCloseIfNothingRead, int *ret) 102 { 103 *ret = soread(pData, so, fCloseIfNothingRead); 104 } 105 #endif 97 106 98 107 /* … … 109 118 struct iovec iov[2]; 110 119 int mss = so->so_tcpcb->t_maxseg; 120 Log2(("%s:%d soread before lock\n", __FUNCTION__, __LINE__)); 121 QSOCKET_LOCK(tcb); 122 SOCKET_LOCK(so); 123 QSOCKET_UNLOCK(tcb); 124 Log2(("%s:%d soread before lock\n",__FUNCTION__, __LINE__)); 111 125 112 126 DEBUG_CALL("soread"); … … 190 204 */ 191 205 if (nn == 0 && !fCloseIfNothingRead) 206 { 207 SOCKET_UNLOCK(so); 192 208 return 0; 209 } 193 210 #endif 194 211 if (nn < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) 212 { 213 SOCKET_UNLOCK(so); 195 214 return 0; 215 } 196 216 else 197 217 { … … 201 221 sofcantrcvmore(so); 202 222 tcp_sockclosed(pData, sototcpcb(so)); 223 SOCKET_UNLOCK(so); 203 224 return -1; 204 225 } … … 231 252 if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen)) 232 253 sb->sb_wptr -= sb->sb_datalen; 254 SOCKET_UNLOCK(so); 233 255 return nn; 234 256 } … … 344 366 DEBUG_CALL("sowrite"); 345 367 DEBUG_ARG("so = %lx", (long)so); 346 368 QSOCKET_LOCK(tcb); 369 SOCKET_LOCK(so); 370 QSOCKET_UNLOCK(tcb); 347 371 if (so->so_urgc) 348 372 { 349 373 sosendoob(so); 350 374 if (sb->sb_cc == 0) 375 { 376 SOCKET_UNLOCK(so); 351 377 return 0; 378 } 352 379 } 353 380 … … 396 423 /* This should never happen, but people tell me it does *shrug* */ 397 424 if (nn < 0 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)) 425 { 426 SOCKET_UNLOCK(so); 398 427 return 0; 428 } 399 429 400 430 if (nn < 0 || (nn == 0 && iov[0].iov_len > 0)) … … 404 434 sofcantsendmore(so); 405 435 tcp_sockclosed(pData, sototcpcb(so)); 436 SOCKET_UNLOCK(so); 406 437 return -1; 407 438 } … … 431 462 sofcantsendmore(so); 432 463 464 SOCKET_UNLOCK(so); 433 465 return nn; 434 466 } … … 463 495 u_long n; 464 496 465 if (!(m = m_get(pData))) 497 QSOCKET_LOCK(udb); 498 SOCKET_LOCK(so); 499 QSOCKET_UNLOCK(udb); 500 501 if (!(m = m_get(pData))) 502 { 503 SOCKET_UNLOCK(so); 466 504 return; 505 } 467 506 m->m_data += if_maxlinkhdr; 468 507 #ifdef VBOX_WITH_SIMPLIFIED_SLIRP_SYNC … … 490 529 m->m_len = recvfrom(so->s, m->m_data, len, 0, 491 530 (struct sockaddr *)&addr, &addrlen); 492 DEBUG_MISC((dfd," did recvfrom %d, errno = %d-%s\n",531 Log2((" did recvfrom %d, errno = %d-%s\n", 493 532 m->m_len, errno,strerror(errno))); 494 533 if(m->m_len < 0) … … 501 540 code = ICMP_UNREACH_NET; 502 541 503 DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));542 Log2((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code)); 504 543 icmp_error(pData, so->so_m, ICMP_UNREACH,code, 0,strerror(errno)); 505 544 m_free(pData, m); … … 534 573 */ 535 574 udp_output(pData, so, m, &addr); 575 SOCKET_UNLOCK(so); 536 576 } /* rx error */ 537 577 } /* if ping packet */ … … 678 718 int tmperrno = WSAGetLastError(); /* Don't clobber the real reason we failed */ 679 719 closesocket(s); 720 QSOCKET_LOCK(tcb); 680 721 sofree(pData, so); 722 QSOCKET_UNLOCK(tcb); 681 723 /* Restore the real errno */ 682 724 WSASetLastError(tmperrno);
Note:
See TracChangeset
for help on using the changeset viewer.