Changeset 13783 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Nov 4, 2008 12:48:28 PM (16 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/if.c
r13740 r13783 50 50 51 51 VBOX_SLIRP_LOCK_CREATE(&pData->if_fastq_mutex); 52 VBOX_SLIRP_LOCK_CREATE(&if_fastq.m_mutex);53 52 54 53 if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq; 55 54 56 55 VBOX_SLIRP_LOCK_CREATE(&pData->if_batchq_mutex); 57 VBOX_SLIRP_LOCK_CREATE(&if_batchq.m_mutex);58 56 59 57 /* sl_compress_init(&comp_s); */ … … 173 171 */ 174 172 VBOX_SLIRP_LOCK(pData->m_usedlist_mutex); 175 VBOX_SLIRP_LOCK(ifm->m_mutex);176 173 177 174 if (ifm->m_flags & M_USEDLIST) { … … 200 197 ifqprev = ifq->ifq_prev; 201 198 #endif 202 VBOX_SLIRP_LOCK(ifq->m_mutex);203 199 VBOX_SLIRP_UNLOCK(pData->if_batchq_mutex); 204 200 if (so == ifq->ifq_so) { … … 208 204 goto diddit; 209 205 } 210 VBOX_SLIRP_UNLOCK(ifq->m_mutex);211 206 VBOX_SLIRP_LOCK(pData->if_batchq_mutex); 212 207 #ifdef VBOX_WITH_SYNC_SLIRP … … 219 214 VBOX_SLIRP_LOCK(pData->if_fastq_mutex); 220 215 ifq = if_fastq.ifq_prev; 221 VBOX_SLIRP_LOCK(ifq->m_mutex);222 216 VBOX_SLIRP_UNLOCK(pData->if_fastq_mutex); 223 217 on_fastq = 1; … … 235 229 VBOX_SLIRP_LOCK(pData->if_batchq_mutex); 236 230 ifq = if_batchq.ifq_prev; 237 if (ifq != &if_batchq) {238 VBOX_SLIRP_LOCK(ifq->m_mutex);239 }240 231 VBOX_SLIRP_UNLOCK(pData->if_batchq_mutex); 241 232 } … … 255 246 if (so) { 256 247 /* Update *_queued */ 257 VBOX_SLIRP_LOCK(so->so_mutex);258 248 so->so_queued++; 259 249 so->so_nqueued++; … … 279 269 VBOX_SLIRP_UNLOCK(pData->if_batchq_mutex); 280 270 } 281 VBOX_SLIRP_UNLOCK(so->so_mutex); 282 } 283 VBOX_SLIRP_UNLOCK(ifq->m_mutex); 284 VBOX_SLIRP_UNLOCK(ifm->m_mutex); 271 } 285 272 286 273 #ifndef FULL_BOLT … … 341 328 on_fast = 1; 342 329 #endif 343 VBOX_SLIRP_LOCK(ifm->m_mutex);344 330 VBOX_SLIRP_UNLOCK(pData->if_fastq_mutex); 345 331 } else { … … 359 345 VBOX_SLIRP_UNLOCK(pData->if_batchq_mutex); 360 346 } 361 VBOX_SLIRP_LOCK(ifm->m_mutex);362 347 VBOX_SLIRP_LOCK(pData->if_queued_mutex); 363 348 #ifdef VBOX_WITH_SYNC_SLIRP … … 373 358 /* Remove it from the queue */ 374 359 ifqt = ifm->ifq_prev; 375 remque(pData, ifm); 360 if (ifm->m_prev != ifm && ifm->m_prev != NULL) 361 remque(pData, ifm); 376 362 377 363 --if_queued; … … 387 373 388 374 /* If there are more packets for this session, re-queue them */ 389 if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm ) {375 if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm && ifm->ifs_next != NULL) { 390 376 insque(pData, ifm->ifs_next, ifqt); 391 377 ifs_remque(ifm); … … 394 380 /* Update so_queued */ 395 381 if (ifm->ifq_so) { 396 VBOX_SLIRP_LOCK(ifm->ifq_so->so_mutex);397 382 if (--ifm->ifq_so->so_queued == 0) 398 383 /* If there's no more queued, reset nqueued */ 399 384 ifm->ifq_so->so_nqueued = 0; 400 VBOX_SLIRP_UNLOCK(ifm->ifq_so->so_mutex);401 385 } 402 386 … … 406 390 m_free(pData, ifm); 407 391 408 if (ifm != NULL)VBOX_SLIRP_UNLOCK(ifm->m_mutex); 409 VBOX_SLIRP_LOCK(pData->if_queued_mutex); 392 VBOX_SLIRP_LOCK(pData->if_queued_mutex); 410 393 /*We release if_queued_mutex after again label and before return*/ 411 394 -
trunk/src/VBox/Devices/Network/slirp/ip_input.c
r13710 r13783 77 77 DEBUG_ARG("m_len = %d", m->m_len); 78 78 79 VBOX_SLIRP_LOCK(m->m_mutex);80 79 81 80 ipstat.ips_total++; … … 83 82 if (m->m_len < sizeof (struct ip)) { 84 83 ipstat.ips_toosmall++; 85 VBOX_SLIRP_UNLOCK(m->m_mutex);86 84 return; 87 85 } … … 197 195 ip = ip_reass(pData, (struct ipasfrag *)ip, fp); 198 196 if (ip == 0) { 199 VBOX_SLIRP_UNLOCK(m->m_mutex);200 197 return; 201 198 } 202 199 ipstat.ips_reassembled++; 203 VBOX_SLIRP_UNLOCK(m->m_mutex);204 200 m = dtom(pData, ip); 205 VBOX_SLIRP_LOCK(m->m_mutex);206 201 } else 207 202 if (fp) … … 229 224 m_free(pData, m); 230 225 } 231 if (m != NULL) {232 VBOX_SLIRP_UNLOCK(m->m_mutex);233 }234 226 return; 235 227 bad: 236 228 m_freem(pData, m); 237 if (m != NULL) {238 VBOX_SLIRP_UNLOCK(m->m_mutex);239 }240 229 return; 241 230 } -
trunk/src/VBox/Devices/Network/slirp/mbuf.c
r13710 r13783 72 72 } 73 73 74 VBOX_SLIRP_LOCK_CREATE(&m->m_mutex);75 74 VBOX_SLIRP_LOCK(pData->mbuf_alloced_mutex); 76 75 … … 86 85 } 87 86 88 VBOX_SLIRP_LOCK(m->m_mutex);89 87 VBOX_SLIRP_UNLOCK(pData->m_freelist_mutex); 90 88 … … 103 101 m->m_prevpkt = 0; 104 102 105 VBOX_SLIRP_UNLOCK(m->m_mutex);106 103 end_error: 107 104 DEBUG_ARG("m = %lx", (long )m); … … 118 115 if(m) { 119 116 /* Remove from m_usedlist */ 120 VBOX_SLIRP_LOCK(m->m_mutex);121 117 if (m->m_flags & M_USEDLIST) { 122 118 VBOX_SLIRP_LOCK(pData->m_usedlist_mutex); … … 134 130 if (m->m_flags & M_DOFREE) { 135 131 u32ptr_done(pData, ptr_to_u32(pData, m), m); 136 VBOX_SLIRP_UNLOCK(m->m_mutex);137 VBOX_SLIRP_LOCK_DESTROY(m->m_mutex);138 132 free(m); 139 133 #ifdef VBOX_WITH_SYNC_SLIRP … … 149 143 VBOX_SLIRP_UNLOCK(pData->m_freelist_mutex); 150 144 } 151 if (m != NULL) VBOX_SLIRP_UNLOCK(m->m_mutex);152 145 } /* if(m) */ 153 146 } … … 164 157 * If there's no room, realloc 165 158 */ 166 VBOX_SLIRP_LOCK(m->m_mutex);167 VBOX_SLIRP_LOCK(n->m_mutex);168 159 169 160 if (M_FREEROOM(m) < n->m_len) … … 175 166 m_free(pData, n); 176 167 177 VBOX_SLIRP_UNLOCK(m->m_mutex);178 if (n != NULL) VBOX_SLIRP_UNLOCK(n->m_mutex);179 168 } 180 169 … … 189 178 190 179 /* some compiles throw up on gotos. This one we can fake. */ 191 VBOX_SLIRP_LOCK(m->m_mutex);192 180 if(m->m_size>size) { 193 VBOX_SLIRP_UNLOCK(m->m_mutex);194 181 return; 195 182 } … … 217 204 218 205 m->m_size = size; 219 VBOX_SLIRP_UNLOCK(m->m_mutex);220 206 } 221 207 … … 229 215 if (m == NULL) 230 216 return; 231 VBOX_SLIRP_LOCK(m->m_mutex);232 217 if (len >= 0) { 233 218 /* Trim from head */ … … 239 224 m->m_len -= len; 240 225 } 241 VBOX_SLIRP_UNLOCK(m->m_mutex);242 226 } 243 227 … … 251 235 int off, len; 252 236 { 253 VBOX_SLIRP_LOCK(m->m_mutex);254 VBOX_SLIRP_LOCK(n->m_mutex);255 237 if (len > M_FREEROOM(n)) { 256 VBOX_SLIRP_UNLOCK(n->m_mutex);257 VBOX_SLIRP_UNLOCK(m->m_mutex);258 238 return -1; 259 239 } … … 261 241 memcpy((n->m_data + n->m_len), (m->m_data + off), len); 262 242 n->m_len += len; 263 VBOX_SLIRP_UNLOCK(n->m_mutex);264 VBOX_SLIRP_UNLOCK(m->m_mutex);265 243 return 0; 266 244 } … … 288 266 m = m_usedlist.m_next; 289 267 while(1) { 290 VBOX_SLIRP_LOCK(m->m_mutex);291 268 mnext = m->m_next; 292 VBOX_SLIRP_UNLOCK(pData->m_usedlist_mutex);293 269 #endif 294 270 if (m->m_flags & M_EXT) { 295 271 if( (char *)dat>=m->m_ext && (char *)dat<(m->m_ext + m->m_size) ) { 296 VBOX_SLIRP_UNLOCK(m->m_mutex);297 272 return m; 298 273 } 299 274 } else { 300 275 if( (char *)dat >= m->m_dat && (char *)dat<(m->m_dat + m->m_size) ) { 301 VBOX_SLIRP_UNLOCK(m->m_mutex);302 276 return m; 303 277 } 304 278 } 305 VBOX_SLIRP_UNLOCK(m->m_mutex);306 VBOX_SLIRP_LOCK(pData->m_usedlist_mutex);307 279 #ifdef VBOX_WITH_SYNC_SLIRP 308 280 m = mnext; -
trunk/src/VBox/Devices/Network/slirp/mbuf.h
r13738 r13783 76 76 caddr_t mh_data; /* Location of data */ 77 77 int mh_len; /* Amount of data in this mbuf */ 78 #ifdef VBOX_WITH_SYNC_SLIRP79 RTSEMFASTMUTEX mh_mutex;80 #endif81 78 }; 82 79 -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r13776 r13783 384 384 #endif 385 385 so_next = so->so_next; 386 #ifdef VBOX_WITH_SYNC_SLIRP387 VBOX_SLIRP_LOCK(so->so_mutex);388 while (so->so_destroy == 1) {389 VBOX_SLIRP_UNLOCK(so->so_mutex);390 VBOX_SLIRP_LOCK_DESTROY(so->so_mutex);391 free(so);392 so = so_next;393 so_next = so->so_next;394 if (so == &tcb) {395 goto tcp_loop_begin;396 }397 VBOX_SLIRP_LOCK(so->so_mutex);398 }399 #endif400 386 VBOX_SLIRP_UNLOCK(pData->tcb_mutex); 401 387 … … 403 389 * See if we need a tcp_fasttimo 404 390 */ 405 if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) 391 if (time_fasttimo == 0 392 && so->so_tcpcb 393 && so->so_tcpcb->t_flags & TF_DELACK) 406 394 time_fasttimo = curtime; /* Flag when we want a fasttimo */ 407 395 … … 451 439 before_loop_ends: 452 440 /*Release of global tcb mutex happens in the head of loop*/ 453 VBOX_SLIRP_UNLOCK(so->so_mutex);454 441 VBOX_SLIRP_LOCK(pData->tcb_mutex); 455 442 #ifdef VBOX_WITH_SYNC_SLIRP … … 473 460 #endif 474 461 so_next = so->so_next; 475 VBOX_SLIRP_LOCK(so->so_mutex);476 462 VBOX_SLIRP_UNLOCK(pData->udb_mutex); 477 463 … … 502 488 } 503 489 before_udp_loop_end: 504 VBOX_SLIRP_UNLOCK(so->so_mutex);505 490 VBOX_SLIRP_LOCK(pData->udb_mutex); 506 491 #ifdef VBOX_WITH_SYNC_SLIRP … … 591 576 592 577 593 VBOX_SLIRP_LOCK(so->so_mutex);594 #ifdef VBOX_WITH_SYNC_SLIRP595 while (so->so_destroy == 1) {596 VBOX_SLIRP_UNLOCK(so->so_mutex);597 VBOX_SLIRP_LOCK_DESTROY(so->so_mutex);598 free(so);599 so = so_next;600 so_next = so->so_next;601 if (so == &tcb)602 goto loop_begin;603 VBOX_SLIRP_LOCK(so->so_mutex);604 }605 #endif606 578 VBOX_SLIRP_UNLOCK(pData->tcb_mutex); 607 579 … … 719 691 #endif 720 692 before_loop_ends: 721 VBOX_SLIRP_UNLOCK(so->so_mutex);722 693 VBOX_SLIRP_LOCK(pData->tcb_mutex); 723 694 #ifdef VBOX_WITH_SYNC_SLIRP … … 743 714 #endif 744 715 so_next = so->so_next; 745 VBOX_SLIRP_LOCK(so->so_mutex);746 716 VBOX_SLIRP_UNLOCK(pData->udb_mutex); 747 717 … … 749 719 sorecvfrom(pData, so); 750 720 } 751 VBOX_SLIRP_UNLOCK(so->so_mutex);752 721 VBOX_SLIRP_LOCK(pData->udb_mutex); 753 722 #ifdef VBOX_WITH_SYNC_SLIRP … … 884 853 if (!m) 885 854 return; 886 VBOX_SLIRP_LOCK(m->m_mutex);887 855 /* Note: we add to align the IP header */ 888 856 if (M_FREEROOM(m) < pkt_len + 2) { … … 896 864 897 865 ip_input(pData, m); 898 VBOX_SLIRP_UNLOCK(m->m_mutex);899 866 break; 900 867 default: -
trunk/src/VBox/Devices/Network/slirp/socket.c
r13738 r13783 64 64 so->so_state = SS_NOFDREF; 65 65 so->s = -1; 66 VBOX_SLIRP_LOCK_CREATE(&so->so_mutex);67 66 } 68 67 return(so); … … 92 91 /*Take global mutexes of udb and tcb, because we dont know which is mutex */ 93 92 /*XXX: don't forget to set correct so_type in corresponded attach operation */ 94 VBOX_SLIRP_LOCK(so->so_mutex);95 93 if (so->so_emu==EMU_RSH && so->extra) { 96 94 sofree(pData, so->extra); … … 113 111 udp_last_so = &udb; 114 112 115 #if 0116 113 if(so->so_next && so->so_prev) { 117 114 remque(pData, so); /* crashes if so is not in a queue */ 118 115 } 119 #else 120 remque(pData, so); /* crashes if so is not in a queue */ 121 #endif 116 122 117 if (so->so_type == IPPROTO_UDP) { 123 118 VBOX_SLIRP_UNLOCK(pData->udp_last_so_mutex); … … 132 127 133 128 m_free(pData, so->so_m); 134 so->so_destroy = 1; 135 136 137 VBOX_SLIRP_UNLOCK(so->so_mutex); 129 free(so); 130 131 138 132 #endif 139 133 … … 156 150 struct iovec iov[2]; 157 151 int mss; 158 VBOX_SLIRP_LOCK(so->so_mutex);159 152 sb = &so->so_snd; 160 VBOX_SLIRP_UNLOCK(so->so_mutex);161 153 len = sb->sb_datalen - sb->sb_cc; 162 154 mss = so->so_tcpcb->t_maxseg; … … 213 205 } 214 206 215 VBOX_SLIRP_LOCK(so->so_mutex);216 207 #ifdef HAVE_READV 217 208 nn = readv(so->s, (struct iovec *)iov, n); … … 222 213 if (nn <= 0) { 223 214 if (nn < 0 && (errno == EINTR || errno == EAGAIN)) { 224 VBOX_SLIRP_UNLOCK(so->so_mutex);225 215 return 0; 226 216 } … … 229 219 sofcantrcvmore(so); 230 220 tcp_sockclosed(pData, sototcpcb(so)); 231 VBOX_SLIRP_UNLOCK(so->so_mutex);232 221 return -1; 233 222 } 234 223 } 235 VBOX_SLIRP_UNLOCK(so->so_mutex);236 224 237 225 #ifndef HAVE_READV … … 274 262 { 275 263 struct tcpcb *tp; 276 VBOX_SLIRP_LOCK(so->so_mutex);277 264 tp = sototcpcb(so); 278 265 … … 290 277 soread(pData, so); 291 278 tp->snd_up = tp->snd_una + so->so_snd.sb_cc; 292 VBOX_SLIRP_UNLOCK(so->so_mutex);293 279 tp->t_force = 1; 294 280 tcp_output(pData, tp); … … 309 295 int n, len; 310 296 311 VBOX_SLIRP_LOCK(so->so_mutex);312 297 sb = &so->so_rcv; 313 298 … … 355 340 sb->sb_rptr -= sb->sb_datalen; 356 341 357 VBOX_SLIRP_UNLOCK(so->so_mutex);358 342 return n; 359 343 } … … 370 354 int len; 371 355 struct iovec iov[2]; 372 VBOX_SLIRP_LOCK(so->so_mutex);373 356 sb = &so->so_rcv; 374 357 len = sb->sb_cc; … … 380 363 sosendoob(so); 381 364 if (sb->sb_cc == 0) { 382 VBOX_SLIRP_UNLOCK(so->so_mutex);383 365 return 0; 384 366 } … … 423 405 /* This should never happen, but people tell me it does *shrug* */ 424 406 if (nn < 0 && (errno == EAGAIN || errno == EINTR)) { 425 VBOX_SLIRP_UNLOCK(so->so_mutex);426 407 return 0; 427 408 } … … 432 413 sofcantsendmore(so); 433 414 tcp_sockclosed(pData, sototcpcb(so)); 434 VBOX_SLIRP_UNLOCK(so->so_mutex);435 415 return -1; 436 416 } … … 459 439 sofcantsendmore(so); 460 440 461 VBOX_SLIRP_UNLOCK(so->so_mutex);462 441 return nn; 463 442 } … … 475 454 DEBUG_ARG("so = %lx", (long)so); 476 455 477 VBOX_SLIRP_LOCK(so->so_mutex);478 456 479 457 if (so->so_type == IPPROTO_ICMP) { /* This is a "ping" reply */ … … 562 540 } /* rx error */ 563 541 } /* if ping packet */ 564 VBOX_SLIRP_UNLOCK(so->so_mutex);565 542 } 566 543 … … 576 553 struct sockaddr_in host_addr; 577 554 #endif 578 VBOX_SLIRP_LOCK(so->so_mutex);579 555 580 556 DEBUG_CALL("sosendto"); … … 629 605 (struct sockaddr *)&addr, sizeof (struct sockaddr)); 630 606 if (ret < 0) { 631 VBOX_SLIRP_UNLOCK(so->so_mutex);632 607 return -1; 633 608 } … … 640 615 so->so_expire = curtime + SO_EXPIRE; 641 616 so->so_state = SS_ISFCONNECTED; /* So that it gets select()ed */ 642 VBOX_SLIRP_UNLOCK(so->so_mutex);643 617 return 0; 644 618 } … … 676 650 677 651 VBOX_SLIRP_LOCK(pData->tcb_mutex); 678 VBOX_SLIRP_LOCK(so->so_mutex);679 652 insque(pData, so,&tcb); 680 653 VBOX_SLIRP_UNLOCK(pData->tcb_mutex); … … 711 684 errno = tmperrno; 712 685 #endif 713 if(so != NULL) VBOX_SLIRP_UNLOCK(so->so_mutex);714 686 return NULL; 715 687 } … … 725 697 so->s = s; 726 698 727 VBOX_SLIRP_UNLOCK(so->so_mutex);728 699 return so; 729 700 } … … 764 735 register struct socket *so; 765 736 { 766 VBOX_SLIRP_LOCK(so->so_mutex);767 737 so->so_state &= ~(SS_NOFDREF|SS_ISFCONNECTED|SS_FCANTRCVMORE| 768 738 SS_FCANTSENDMORE|SS_FWDRAIN); 769 739 so->so_state |= SS_ISFCONNECTING; /* Clobber other states */ 770 VBOX_SLIRP_UNLOCK(so->so_mutex);771 740 } 772 741 … … 775 744 register struct socket *so; 776 745 { 777 VBOX_SLIRP_LOCK(so->so_mutex);778 746 so->so_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF); 779 747 so->so_state |= SS_ISFCONNECTED; /* Clobber other states */ 780 VBOX_SLIRP_UNLOCK(so->so_mutex);781 748 } 782 749 … … 785 752 struct socket *so; 786 753 { 787 VBOX_SLIRP_LOCK(so->so_mutex);788 754 if ((so->so_state & SS_NOFDREF) == 0) { 789 755 shutdown(so->s,0); … … 794 760 else 795 761 so->so_state |= SS_FCANTRCVMORE; 796 VBOX_SLIRP_UNLOCK(so->so_mutex);797 762 } 798 763 … … 801 766 struct socket *so; 802 767 { 803 VBOX_SLIRP_LOCK(so->so_mutex);804 768 if ((so->so_state & SS_NOFDREF) == 0) { 805 769 shutdown(so->s,1); /* send FIN to fhost */ … … 810 774 else 811 775 so->so_state |= SS_FCANTSENDMORE; 812 VBOX_SLIRP_UNLOCK(so->so_mutex);813 776 } 814 777 … … 833 796 struct socket *so; 834 797 { 835 VBOX_SLIRP_LOCK(so->so_mutex);836 798 if (so->so_rcv.sb_cc) 837 799 so->so_state |= SS_FWDRAIN; 838 800 else 839 801 sofcantsendmore(so); 840 VBOX_SLIRP_UNLOCK(so->so_mutex); 841 } 842 802 } 803 -
trunk/src/VBox/Devices/Network/slirp/socket.h
r13738 r13783 55 55 struct sbuf so_snd; /* Send buffer */ 56 56 void * extra; /* Extra pointer */ 57 #ifdef VBOX_WITH_SYNC_SLIRP58 RTSEMFASTMUTEX so_mutex; /*per socket mutex*/59 int so_destroy;60 #endif61 57 }; 62 58 -
trunk/src/VBox/Devices/Network/slirp/tcp_input.c
r13738 r13783 256 256 #endif 257 257 258 if (inso != NULL) {259 VBOX_SLIRP_LOCK(inso->so_mutex);260 }261 262 258 /* 263 259 * If called with m == 0, then we're continuing the connect … … 269 265 tp = sototcpcb(so); 270 266 m = so->so_m; 271 VBOX_SLIRP_LOCK(m->m_mutex);272 267 so->so_m = 0; 273 268 ti = so->so_ti; … … 277 272 goto cont_conn; 278 273 } 279 if (inso != NULL) {280 VBOX_SLIRP_UNLOCK(inso->so_mutex);281 }282 VBOX_SLIRP_LOCK(m->m_mutex);283 274 284 275 … … 374 365 */ 375 366 findso: 376 if (so != NULL) {377 VBOX_SLIRP_UNLOCK(so->so_mutex);378 }379 367 VBOX_SLIRP_LOCK(pData->tcp_last_so_mutex); 380 368 so = tcp_last_so; 381 369 /* this checking for making sure that we're not trying to hold mutex on head list*/ 382 if (tcp_last_so != &tcb) {383 VBOX_SLIRP_LOCK(so->so_mutex);384 }385 370 VBOX_SLIRP_UNLOCK(pData->tcp_last_so_mutex); 386 371 … … 390 375 so->so_faddr.s_addr != ti->ti_dst.s_addr) { 391 376 /*To make sure that we don't try to release mutex on head of the socket queue*/ 392 if (so != &tcb) {393 VBOX_SLIRP_UNLOCK(so->so_mutex);394 }395 377 so = solookup(&tcb, ti->ti_src, ti->ti_sport, 396 378 ti->ti_dst, ti->ti_dport); 397 379 if (so) { 398 VBOX_SLIRP_LOCK(so->so_mutex);399 380 VBOX_SLIRP_LOCK(pData->tcp_last_so_mutex); 400 381 tcp_last_so = so; … … 424 405 goto dropwithreset; 425 406 426 if (inso != NULL) VBOX_SLIRP_UNLOCK(inso->so_mutex);427 407 if (tcp_attach(pData, so) < 0) { 428 VBOX_SLIRP_UNLOCK(so->so_mutex);429 VBOX_SLIRP_LOCK_DESTROY(so->so_mutex);430 408 free(so); /* Not sofree (if it failed, it's not insqued) */ 431 409 #ifdef VBOX_WITH_SYNC_SLIRP … … 434 412 goto dropwithreset; 435 413 } 436 VBOX_SLIRP_LOCK(so->so_mutex);437 414 438 415 sbreserve(&so->so_snd, tcp_sndspace); … … 550 527 tp->snd_una = ti->ti_ack; 551 528 m_freem(pData, m); 552 if (m != NULL) {553 VBOX_SLIRP_UNLOCK(m->m_mutex);554 }555 529 556 530 /* … … 582 556 if (so->so_snd.sb_cc) 583 557 (void) tcp_output(pData, tp); 584 VBOX_SLIRP_UNLOCK(so->so_mutex);585 558 return; 586 559 } … … 622 595 tp->t_flags |= TF_ACKNOW; 623 596 tcp_output(pData, tp); 624 VBOX_SLIRP_UNLOCK(so->so_mutex);625 if (m != NULL) {626 VBOX_SLIRP_UNLOCK(m->m_mutex);627 }628 597 return; 629 598 } … … 726 695 tp = tcp_close(pData, tp); 727 696 m_free(pData, m); 728 if (m != NULL) {729 VBOX_SLIRP_UNLOCK(m->m_mutex);730 }731 697 } else { 732 698 /* … … 741 707 tp->t_state = TCPS_SYN_RECEIVED; 742 708 } 743 VBOX_SLIRP_UNLOCK(so->so_mutex);744 if (m != NULL) {745 VBOX_SLIRP_UNLOCK(m->m_mutex);746 }747 709 return; 748 710 … … 1503 1465 } 1504 1466 1505 VBOX_SLIRP_UNLOCK(so->so_mutex);1506 if (m != NULL) {1507 VBOX_SLIRP_UNLOCK(m->m_mutex);1508 }1509 1467 return; 1510 1468 … … 1519 1477 tp->t_flags |= TF_ACKNOW; 1520 1478 (void) tcp_output(pData, tp); 1521 VBOX_SLIRP_UNLOCK(so->so_mutex);1522 if (m != NULL) {1523 VBOX_SLIRP_UNLOCK(m->m_mutex);1524 }1525 1479 return; 1526 1480 … … 1535 1489 } 1536 1490 1537 if (so != NULL) VBOX_SLIRP_UNLOCK(so->so_mutex);1538 if (m != NULL) VBOX_SLIRP_UNLOCK(m->m_mutex);1539 1491 return; 1540 1492 … … 1544 1496 */ 1545 1497 m_free(pData, m); 1546 VBOX_SLIRP_UNLOCK(so->so_mutex);1547 if (m != NULL) {1548 VBOX_SLIRP_UNLOCK(m->m_mutex);1549 }1550 1551 1498 return; 1552 1499 #ifdef VBOX_WITH_SYNC_SLIRP -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r13738 r13783 276 276 */ 277 277 /* free(tp, M_PCB); */ 278 VBOX_SLIRP_LOCK(so->so_mutex);279 278 280 279 u32ptr_done(pData, ptr_to_u32(pData, tp), tp); … … 291 290 sbfree(&so->so_snd); 292 291 sofree(pData, so); 293 if(so != NULL) VBOX_SLIRP_UNLOCK(so->so_mutex);294 292 tcpstat.tcps_closed++; 295 293 return ((struct tcpcb *)0); … … 453 451 DEBUG_CALL("tcp_connect"); 454 452 DEBUG_ARG("inso = %lx", (long)inso); 455 VBOX_SLIRP_LOCK(inso->so_mutex);456 453 457 454 /* … … 463 460 so = inso; 464 461 } else { 465 VBOX_SLIRP_UNLOCK(inso->so_mutex);466 462 if ((so = socreate()) == NULL) { 467 463 /* If it failed, get rid of the pending connection */ 468 464 closesocket(accept(inso->s,(struct sockaddr *)&addr,&addrlen)); 469 VBOX_SLIRP_UNLOCK(inso->so_mutex);470 465 return; 471 466 } 472 VBOX_SLIRP_LOCK(so->so_mutex);473 467 if (tcp_attach(pData, so) < 0) { 474 if(so != NULL) VBOX_SLIRP_UNLOCK(so->so_mutex);475 468 free(so); /* NOT sofree */ 476 469 return; … … 484 477 if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) { 485 478 tcp_close(pData, sototcpcb(so)); /* This will sofree() as well */ 486 if (so != inso) {487 VBOX_SLIRP_UNLOCK(inso->so_mutex);488 }489 VBOX_SLIRP_UNLOCK(so->so_mutex);490 479 return; 491 480 } … … 510 499 /* if it's not FACCEPTONCE, it's already NOFDREF */ 511 500 } 512 if (so != inso) {513 VBOX_SLIRP_UNLOCK(inso->so_mutex);514 }515 501 so->s = s; 516 502 … … 535 521 tcp_sendseqinit(tp); 536 522 tcp_output(pData, tp); 537 VBOX_SLIRP_UNLOCK(so->so_mutex);538 523 } 539 524 … … 550 535 551 536 VBOX_SLIRP_LOCK(pData->tcb_mutex); 552 VBOX_SLIRP_LOCK(so->so_mutex);553 537 insque(pData, so, &tcb); 554 538 VBOX_SLIRP_UNLOCK(pData->tcb_mutex); … … 559 543 #endif 560 544 561 VBOX_SLIRP_UNLOCK(so->so_mutex);562 545 return 0; 563 546 } -
trunk/src/VBox/Devices/Network/slirp/tcp_timer.c
r13727 r13783 64 64 } 65 65 so_next = so->so_next; 66 VBOX_SLIRP_LOCK(so->so_mutex);67 66 VBOX_SLIRP_UNLOCK(pData->tcb_mutex); 68 67 #endif … … 74 73 (void) tcp_output(pData, tp); 75 74 } 76 VBOX_SLIRP_UNLOCK(so->so_mutex);77 75 VBOX_SLIRP_LOCK(pData->tcb_mutex); 78 76 #ifdef VBOX_WITH_SYNC_SLIRP … … 117 115 } 118 116 ipnxt = ip->so_next; 119 VBOX_SLIRP_LOCK(ip->so_mutex);120 117 VBOX_SLIRP_UNLOCK(pData->tcb_mutex); 121 118 #endif … … 137 134 ; 138 135 before_loop_ends: 139 VBOX_SLIRP_UNLOCK(ip->so_mutex);140 136 VBOX_SLIRP_LOCK(pData->tcb_mutex); 141 137 #ifdef VBOX_WITH_SYNC_SLIRP -
trunk/src/VBox/Devices/Network/slirp/udp.c
r13710 r13783 78 78 DEBUG_ARG("iphlen = %d", iphlen); 79 79 80 VBOX_SLIRP_LOCK(m->m_mutex);81 80 82 81 udpstat.udps_ipackets++; … … 160 159 VBOX_SLIRP_LOCK(pData->udp_last_so_mutex); 161 160 so = udp_last_so; 162 if (so != &udb) {163 VBOX_SLIRP_LOCK(so->so_mutex);164 }165 161 166 162 VBOX_SLIRP_UNLOCK(pData->udp_last_so_mutex); … … 169 165 so->so_laddr.s_addr != ip->ip_src.s_addr) { 170 166 struct socket *tmp; 171 if (so != &udb) {172 /*we don't interesting in this socket any more*/173 VBOX_SLIRP_UNLOCK(so->so_mutex);174 }175 167 #ifndef VBOX_WITH_SYNC_SLIRP 176 168 for (tmp = udb.so_next; tmp != &udb; tmp = tmp->so_next) { … … 186 178 break; /* end of loop*/ 187 179 } 188 VBOX_SLIRP_LOCK(tmp->so_mutex);189 180 VBOX_SLIRP_UNLOCK(pData->udb_mutex); 190 181 tmp_next = tmp->so_next; … … 195 186 break; 196 187 } 197 VBOX_SLIRP_UNLOCK(tmp->so_mutex);198 188 VBOX_SLIRP_LOCK(pData->udb_mutex); 199 189 #ifdef VBOX_WITH_SYNC_SLIRP … … 221 211 */ 222 212 if ((so = socreate()) == NULL) goto bad; 223 VBOX_SLIRP_LOCK(so->so_mutex);224 213 if(udp_attach(pData, so) == -1) { 225 214 DEBUG_MISC((dfd," udp_attach errno = %d-%s\n", … … 274 263 so->so_m=m; /* ICMP backup */ 275 264 276 VBOX_SLIRP_UNLOCK(so->so_mutex);277 VBOX_SLIRP_UNLOCK(m->m_mutex);278 265 return; 279 266 bad: 280 267 m_freem(pData, m); 281 268 /* if (opts) m_freem(opts); */ 282 if (m != NULL) {283 VBOX_SLIRP_UNLOCK(m->m_mutex);284 }285 269 return; 286 270 } … … 292 276 register struct udpiphdr *ui; 293 277 int error = 0; 294 if(so != NULL) {295 VBOX_SLIRP_LOCK(so->so_mutex);296 }297 VBOX_SLIRP_LOCK(m->m_mutex);298 278 299 279 DEBUG_CALL("udp_output"); … … 341 321 342 322 error = ip_output(pData, so, m); 343 if (so != NULL) VBOX_SLIRP_UNLOCK(so->so_mutex);344 VBOX_SLIRP_UNLOCK(m->m_mutex);345 323 return (error); 346 324 } … … 351 329 struct sockaddr_in saddr, daddr; 352 330 int status; 353 VBOX_SLIRP_LOCK(so->so_mutex);354 331 355 332 saddr = *addr; … … 369 346 370 347 status = udp_output2(pData, so, m, &saddr, &daddr, so->so_iptos); 371 VBOX_SLIRP_UNLOCK(so->so_mutex);372 348 return status; 373 349 } … … 377 353 { 378 354 struct sockaddr_in addr; 379 VBOX_SLIRP_LOCK(so->so_mutex);380 355 381 356 if((so->s = socket(AF_INET,SOCK_DGRAM,0)) != -1) { … … 411 386 so->so_type = IPPROTO_UDP; 412 387 #endif 413 VBOX_SLIRP_UNLOCK(so->so_mutex);414 388 return(so->s); 415 389 } … … 419 393 { 420 394 /* Correctly update list if detaching last socket in list. */ 421 VBOX_SLIRP_LOCK(so->so_mutex);422 395 VBOX_SLIRP_LOCK(pData->udp_last_so_mutex); 423 396 if (so == udp_last_so) udp_last_so = &udb; … … 428 401 sofree(pData, so); 429 402 430 if (so != NULL) {431 VBOX_SLIRP_UNLOCK(so->so_mutex);432 }433 403 } 434 404 … … 450 420 if ((udptos[i].fport && ntohs(so->so_fport) == udptos[i].fport) || 451 421 (udptos[i].lport && ntohs(so->so_lport) == udptos[i].lport)) { 452 VBOX_SLIRP_LOCK(so->so_mutex);453 422 so->so_emu = udptos[i].emu; 454 VBOX_SLIRP_UNLOCK(so->so_mutex);455 423 return udptos[i].tos; 456 424 } … … 502 470 } *cu_head; 503 471 504 VBOX_SLIRP_LOCK(so->so_mutex);505 #ifdef VBOX_WITH_SYNC_SLIRP506 #define return \507 do { \508 VBOX_SLIRP_UNLOCK(so->so_mutex); \509 return; \510 }while(0)511 #endif512 472 513 473 switch(so->so_emu) { … … 701 661 return; 702 662 } 703 /*see macro definition in the begining of method*/704 #ifdef VBOX_WITH_SYNC_SLIRP705 return;706 #undef return707 #endif708 663 } 709 664 … … 722 677 so->s = socket(AF_INET,SOCK_DGRAM,0); 723 678 so->so_expire = curtime + SO_EXPIRE; 724 VBOX_SLIRP_LOCK(so->so_mutex);725 679 VBOX_SLIRP_LOCK(pData->udb_mutex); 726 680 insque(pData, so,&udb); … … 733 687 if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) { 734 688 udp_detach(pData, so); 735 VBOX_SLIRP_UNLOCK(so->so_mutex);736 689 return NULL; 737 690 } … … 755 708 756 709 so->so_state = SS_ISFCONNECTED; 757 VBOX_SLIRP_UNLOCK(so->so_mutex);758 710 759 711 return so;
Note:
See TracChangeset
for help on using the changeset viewer.