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,14 +79,14 @@ writen(fd, bptr, n) | ||
| 79 | int total; | 79 | int total; |
| 80 | 80 | ||
| 81 | /* This should succeed most of the time */ | 81 | /* This should succeed most of the time */ |
| 82 | - ret = write(fd, bptr, n); | 82 | + ret = send(fd, bptr, n,0); |
| 83 | if (ret == n || ret <= 0) | 83 | if (ret == n || ret <= 0) |
| 84 | return ret; | 84 | return ret; |
| 85 | 85 | ||
| 86 | /* Didn't write everything, go into the loop */ | 86 | /* Didn't write everything, go into the loop */ |
| 87 | total = ret; | 87 | total = ret; |
| 88 | while (n > total) { | 88 | while (n > total) { |
| 89 | - ret = write(fd, bptr+total, n-total); | 89 | + ret = send(fd, bptr+total, n-total,0); |
| 90 | if (ret <= 0) | 90 | if (ret <= 0) |
| 91 | return ret; | 91 | return ret; |
| 92 | total += ret; | 92 | total += ret; |
| @@ -111,7 +111,7 @@ if_input(ttyp) | @@ -111,7 +111,7 @@ if_input(ttyp) | ||
| 111 | DEBUG_CALL("if_input"); | 111 | DEBUG_CALL("if_input"); |
| 112 | DEBUG_ARG("ttyp = %lx", (long)ttyp); | 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 | DEBUG_MISC((dfd, " read %d bytes\n", if_n)); | 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,7 +414,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) | ||
| 414 | /* Connected */ | 414 | /* Connected */ |
| 415 | so->so_state &= ~SS_ISFCONNECTING; | 415 | so->so_state &= ~SS_ISFCONNECTING; |
| 416 | 416 | ||
| 417 | - ret = write(so->s, &ret, 0); | 417 | + ret = send(so->s, &ret, 0, 0); |
| 418 | if (ret < 0) { | 418 | if (ret < 0) { |
| 419 | /* XXXXX Must fix, zero bytes is a NOP */ | 419 | /* XXXXX Must fix, zero bytes is a NOP */ |
| 420 | if (errno == EAGAIN || errno == EWOULDBLOCK || | 420 | if (errno == EAGAIN || errno == EWOULDBLOCK || |
| @@ -447,7 +447,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) | @@ -447,7 +447,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) | ||
| 447 | */ | 447 | */ |
| 448 | #ifdef PROBE_CONN | 448 | #ifdef PROBE_CONN |
| 449 | if (so->so_state & SS_ISFCONNECTING) { | 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 | if (ret < 0) { | 452 | if (ret < 0) { |
| 453 | /* XXX */ | 453 | /* XXX */ |
| @@ -460,7 +460,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) | @@ -460,7 +460,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) | ||
| 460 | 460 | ||
| 461 | /* tcp_input will take care of it */ | 461 | /* tcp_input will take care of it */ |
| 462 | } else { | 462 | } else { |
| 463 | - ret = write(so->s, &ret, 0); | 463 | + ret = send(so->s, &ret, 0,0); |
| 464 | if (ret < 0) { | 464 | if (ret < 0) { |
| 465 | /* XXX */ | 465 | /* XXX */ |
| 466 | if (errno == EAGAIN || errno == EWOULDBLOCK || | 466 | if (errno == EAGAIN || errno == EWOULDBLOCK || |
| @@ -496,6 +496,15 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) | @@ -496,6 +496,15 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) | ||
| 496 | */ | 496 | */ |
| 497 | if (if_queued && link_up) | 497 | if (if_queued && link_up) |
| 498 | if_start(); | 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 | #define ETH_ALEN 6 | 510 | #define ETH_ALEN 6 |
slirp/slirp.h
| @@ -329,4 +329,8 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err); | @@ -329,4 +329,8 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err); | ||
| 329 | #define max(x,y) ((x) > (y) ? (x) : (y)) | 329 | #define max(x,y) ((x) > (y) ? (x) : (y)) |
| 330 | #endif | 330 | #endif |
| 331 | 331 | ||
| 332 | +#ifdef _WIN32 | ||
| 333 | +#define errno (WSAGetLastError()) | ||
| 334 | +#endif | ||
| 335 | + | ||
| 332 | #endif | 336 | #endif |
slirp/socket.c
| @@ -152,7 +152,7 @@ soread(so) | @@ -152,7 +152,7 @@ soread(so) | ||
| 152 | nn = readv(so->s, (struct iovec *)iov, n); | 152 | nn = readv(so->s, (struct iovec *)iov, n); |
| 153 | DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); | 153 | DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); |
| 154 | #else | 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 | #endif | 156 | #endif |
| 157 | if (nn <= 0) { | 157 | if (nn <= 0) { |
| 158 | if (nn < 0 && (errno == EINTR || errno == EAGAIN)) | 158 | if (nn < 0 && (errno == EINTR || errno == EAGAIN)) |
| @@ -176,7 +176,7 @@ soread(so) | @@ -176,7 +176,7 @@ soread(so) | ||
| 176 | * A return of -1 wont (shouldn't) happen, since it didn't happen above | 176 | * A return of -1 wont (shouldn't) happen, since it didn't happen above |
| 177 | */ | 177 | */ |
| 178 | if (n == 2 && nn == iov[0].iov_len) | 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 | DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); | 181 | DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); |
| 182 | #endif | 182 | #endif |
| @@ -333,7 +333,7 @@ sowrite(so) | @@ -333,7 +333,7 @@ sowrite(so) | ||
| 333 | 333 | ||
| 334 | DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); | 334 | DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); |
| 335 | #else | 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 | #endif | 337 | #endif |
| 338 | /* This should never happen, but people tell me it does *shrug* */ | 338 | /* This should never happen, but people tell me it does *shrug* */ |
| 339 | if (nn < 0 && (errno == EAGAIN || errno == EINTR)) | 339 | if (nn < 0 && (errno == EAGAIN || errno == EINTR)) |
| @@ -349,7 +349,7 @@ sowrite(so) | @@ -349,7 +349,7 @@ sowrite(so) | ||
| 349 | 349 | ||
| 350 | #ifndef HAVE_READV | 350 | #ifndef HAVE_READV |
| 351 | if (n == 2 && nn == iov[0].iov_len) | 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 | DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); | 353 | DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); |
| 354 | #endif | 354 | #endif |
| 355 | 355 | ||
| @@ -572,7 +572,11 @@ solisten(port, laddr, lport, flags) | @@ -572,7 +572,11 @@ solisten(port, laddr, lport, flags) | ||
| 572 | close(s); | 572 | close(s); |
| 573 | sofree(so); | 573 | sofree(so); |
| 574 | /* Restore the real errno */ | 574 | /* Restore the real errno */ |
| 575 | +#ifdef _WIN32 | ||
| 576 | + WSASetLastError(tmperrno); | ||
| 577 | +#else | ||
| 575 | errno = tmperrno; | 578 | errno = tmperrno; |
| 579 | +#endif | ||
| 576 | return NULL; | 580 | return NULL; |
| 577 | } | 581 | } |
| 578 | setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); | 582 | setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); |
| @@ -643,7 +647,9 @@ sofcantrcvmore(so) | @@ -643,7 +647,9 @@ sofcantrcvmore(so) | ||
| 643 | { | 647 | { |
| 644 | if ((so->so_state & SS_NOFDREF) == 0) { | 648 | if ((so->so_state & SS_NOFDREF) == 0) { |
| 645 | shutdown(so->s,0); | 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 | so->so_state &= ~(SS_ISFCONNECTING); | 654 | so->so_state &= ~(SS_ISFCONNECTING); |
| 649 | if (so->so_state & SS_FCANTSENDMORE) | 655 | if (so->so_state & SS_FCANTSENDMORE) |
| @@ -657,9 +663,13 @@ sofcantsendmore(so) | @@ -657,9 +663,13 @@ sofcantsendmore(so) | ||
| 657 | struct socket *so; | 663 | struct socket *so; |
| 658 | { | 664 | { |
| 659 | if ((so->so_state & SS_NOFDREF) == 0) { | 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 | so->so_state &= ~(SS_ISFCONNECTING); | 674 | so->so_state &= ~(SS_ISFCONNECTING); |
| 665 | if (so->so_state & SS_FCANTRCVMORE) | 675 | if (so->so_state & SS_FCANTRCVMORE) |
slirp/tcp_input.c
| @@ -681,7 +681,7 @@ findso: | @@ -681,7 +681,7 @@ findso: | ||
| 681 | goto cont_input; | 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 | u_char code=ICMP_UNREACH_NET; | 685 | u_char code=ICMP_UNREACH_NET; |
| 686 | DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n", | 686 | DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n", |
| 687 | errno,strerror(errno))); | 687 | errno,strerror(errno))); |
slirp/udp.c
| @@ -339,7 +339,11 @@ udp_attach(so) | @@ -339,7 +339,11 @@ udp_attach(so) | ||
| 339 | int lasterrno=errno; | 339 | int lasterrno=errno; |
| 340 | closesocket(so->s); | 340 | closesocket(so->s); |
| 341 | so->s=-1; | 341 | so->s=-1; |
| 342 | +#ifdef _WIN32 | ||
| 343 | + WSASetLastError(lasterrno); | ||
| 344 | +#else | ||
| 342 | errno=lasterrno; | 345 | errno=lasterrno; |
| 346 | +#endif | ||
| 343 | } else { | 347 | } else { |
| 344 | /* success, insert in queue */ | 348 | /* success, insert in queue */ |
| 345 | so->so_expire = curtime + SO_EXPIRE; | 349 | so->so_expire = curtime + SO_EXPIRE; |