Commit 02d2c54cd3e1a65ce4eaf1555b7f73d0a50eaec4
1 parent
890fa6be
windows fixes (Gregory Alexander)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1102 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
6 changed files
with
42 additions
and
15 deletions
slirp/if.c
... | ... | @@ -79,14 +79,14 @@ writen(fd, bptr, n) |
79 | 79 | int total; |
80 | 80 | |
81 | 81 | /* This should succeed most of the time */ |
82 | - ret = write(fd, bptr, n); | |
82 | + ret = send(fd, bptr, n,0); | |
83 | 83 | if (ret == n || ret <= 0) |
84 | 84 | return ret; |
85 | 85 | |
86 | 86 | /* Didn't write everything, go into the loop */ |
87 | 87 | total = ret; |
88 | 88 | while (n > total) { |
89 | - ret = write(fd, bptr+total, n-total); | |
89 | + ret = send(fd, bptr+total, n-total,0); | |
90 | 90 | if (ret <= 0) |
91 | 91 | return ret; |
92 | 92 | total += ret; |
... | ... | @@ -111,7 +111,7 @@ if_input(ttyp) |
111 | 111 | DEBUG_CALL("if_input"); |
112 | 112 | DEBUG_ARG("ttyp = %lx", (long)ttyp); |
113 | 113 | |
114 | - if_n = read(ttyp->fd, (char *)if_inbuff, INBUFF_SIZE); | |
114 | + if_n = recv(ttyp->fd, (char *)if_inbuff, INBUFF_SIZE,0); | |
115 | 115 | |
116 | 116 | DEBUG_MISC((dfd, " read %d bytes\n", if_n)); |
117 | 117 | ... | ... |
slirp/slirp.c
... | ... | @@ -414,7 +414,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) |
414 | 414 | /* Connected */ |
415 | 415 | so->so_state &= ~SS_ISFCONNECTING; |
416 | 416 | |
417 | - ret = write(so->s, &ret, 0); | |
417 | + ret = send(so->s, &ret, 0, 0); | |
418 | 418 | if (ret < 0) { |
419 | 419 | /* XXXXX Must fix, zero bytes is a NOP */ |
420 | 420 | if (errno == EAGAIN || errno == EWOULDBLOCK || |
... | ... | @@ -447,7 +447,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) |
447 | 447 | */ |
448 | 448 | #ifdef PROBE_CONN |
449 | 449 | if (so->so_state & SS_ISFCONNECTING) { |
450 | - ret = read(so->s, (char *)&ret, 0); | |
450 | + ret = recv(so->s, (char *)&ret, 0,0); | |
451 | 451 | |
452 | 452 | if (ret < 0) { |
453 | 453 | /* XXX */ |
... | ... | @@ -460,7 +460,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) |
460 | 460 | |
461 | 461 | /* tcp_input will take care of it */ |
462 | 462 | } else { |
463 | - ret = write(so->s, &ret, 0); | |
463 | + ret = send(so->s, &ret, 0,0); | |
464 | 464 | if (ret < 0) { |
465 | 465 | /* XXX */ |
466 | 466 | if (errno == EAGAIN || errno == EWOULDBLOCK || |
... | ... | @@ -496,6 +496,15 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) |
496 | 496 | */ |
497 | 497 | if (if_queued && link_up) |
498 | 498 | if_start(); |
499 | + | |
500 | + /* clear global file descriptor sets. | |
501 | + * these reside on the stack in vl.c | |
502 | + * so they're unusable if we're not in | |
503 | + * slirp_select_fill or slirp_select_poll. | |
504 | + */ | |
505 | + global_readfds = NULL; | |
506 | + global_writefds = NULL; | |
507 | + global_xfds = NULL; | |
499 | 508 | } |
500 | 509 | |
501 | 510 | #define ETH_ALEN 6 | ... | ... |
slirp/slirp.h
slirp/socket.c
... | ... | @@ -152,7 +152,7 @@ soread(so) |
152 | 152 | nn = readv(so->s, (struct iovec *)iov, n); |
153 | 153 | DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); |
154 | 154 | #else |
155 | - nn = read(so->s, iov[0].iov_base, iov[0].iov_len); | |
155 | + nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0); | |
156 | 156 | #endif |
157 | 157 | if (nn <= 0) { |
158 | 158 | if (nn < 0 && (errno == EINTR || errno == EAGAIN)) |
... | ... | @@ -176,7 +176,7 @@ soread(so) |
176 | 176 | * A return of -1 wont (shouldn't) happen, since it didn't happen above |
177 | 177 | */ |
178 | 178 | if (n == 2 && nn == iov[0].iov_len) |
179 | - nn += read(so->s, iov[1].iov_base, iov[1].iov_len); | |
179 | + nn += recv(so->s, iov[1].iov_base, iov[1].iov_len,0); | |
180 | 180 | |
181 | 181 | DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); |
182 | 182 | #endif |
... | ... | @@ -333,7 +333,7 @@ sowrite(so) |
333 | 333 | |
334 | 334 | DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); |
335 | 335 | #else |
336 | - nn = write(so->s, iov[0].iov_base, iov[0].iov_len); | |
336 | + nn = send(so->s, iov[0].iov_base, iov[0].iov_len,0); | |
337 | 337 | #endif |
338 | 338 | /* This should never happen, but people tell me it does *shrug* */ |
339 | 339 | if (nn < 0 && (errno == EAGAIN || errno == EINTR)) |
... | ... | @@ -349,7 +349,7 @@ sowrite(so) |
349 | 349 | |
350 | 350 | #ifndef HAVE_READV |
351 | 351 | if (n == 2 && nn == iov[0].iov_len) |
352 | - nn += write(so->s, iov[1].iov_base, iov[1].iov_len); | |
352 | + nn += send(so->s, iov[1].iov_base, iov[1].iov_len,0); | |
353 | 353 | DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); |
354 | 354 | #endif |
355 | 355 | |
... | ... | @@ -572,7 +572,11 @@ solisten(port, laddr, lport, flags) |
572 | 572 | close(s); |
573 | 573 | sofree(so); |
574 | 574 | /* Restore the real errno */ |
575 | +#ifdef _WIN32 | |
576 | + WSASetLastError(tmperrno); | |
577 | +#else | |
575 | 578 | errno = tmperrno; |
579 | +#endif | |
576 | 580 | return NULL; |
577 | 581 | } |
578 | 582 | setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); |
... | ... | @@ -643,7 +647,9 @@ sofcantrcvmore(so) |
643 | 647 | { |
644 | 648 | if ((so->so_state & SS_NOFDREF) == 0) { |
645 | 649 | shutdown(so->s,0); |
646 | - FD_CLR(so->s, global_writefds); | |
650 | + if(global_writefds) { | |
651 | + FD_CLR(so->s,global_writefds); | |
652 | + } | |
647 | 653 | } |
648 | 654 | so->so_state &= ~(SS_ISFCONNECTING); |
649 | 655 | if (so->so_state & SS_FCANTSENDMORE) |
... | ... | @@ -657,9 +663,13 @@ sofcantsendmore(so) |
657 | 663 | struct socket *so; |
658 | 664 | { |
659 | 665 | if ((so->so_state & SS_NOFDREF) == 0) { |
660 | - shutdown(so->s,1); /* send FIN to fhost */ | |
661 | - FD_CLR(so->s, global_readfds); | |
662 | - FD_CLR(so->s, global_xfds); | |
666 | + shutdown(so->s,1); /* send FIN to fhost */ | |
667 | + if (global_readfds) { | |
668 | + FD_CLR(so->s,global_readfds); | |
669 | + } | |
670 | + if (global_xfds) { | |
671 | + FD_CLR(so->s,global_xfds); | |
672 | + } | |
663 | 673 | } |
664 | 674 | so->so_state &= ~(SS_ISFCONNECTING); |
665 | 675 | if (so->so_state & SS_FCANTRCVMORE) | ... | ... |
slirp/tcp_input.c
... | ... | @@ -681,7 +681,7 @@ findso: |
681 | 681 | goto cont_input; |
682 | 682 | } |
683 | 683 | |
684 | - if(tcp_fconnect(so) == -1 && errno != EINPROGRESS) { | |
684 | + if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) { | |
685 | 685 | u_char code=ICMP_UNREACH_NET; |
686 | 686 | DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n", |
687 | 687 | errno,strerror(errno))); | ... | ... |
slirp/udp.c
... | ... | @@ -339,7 +339,11 @@ udp_attach(so) |
339 | 339 | int lasterrno=errno; |
340 | 340 | closesocket(so->s); |
341 | 341 | so->s=-1; |
342 | +#ifdef _WIN32 | |
343 | + WSASetLastError(lasterrno); | |
344 | +#else | |
342 | 345 | errno=lasterrno; |
346 | +#endif | |
343 | 347 | } else { |
344 | 348 | /* success, insert in queue */ |
345 | 349 | so->so_expire = curtime + SO_EXPIRE; | ... | ... |