Fixed inet_pton and a new Winsock UDP bug.
inet_pton was copying the entire sockaddr_in struct, rather than just the sin_addr field... I am a bit unsure about the UDP fix, because it may affect TCP as well. On UDP sockets, when a sendto fails, the next receive/receivefrom fails with CONNRESET. I changed sock_recv/sock_recvfrom in wsocket.c to skip the CONNRESET from the recv/recvfrom, hoping that if the socket is TCP, sock_waitfd will get the CONNRESET again. The tests pass, but this should be tested more thoroughly.
This commit is contained in:
parent
66cd8cfcee
commit
734cc23e1f
4 changed files with 84 additions and 69 deletions
|
@ -250,7 +250,11 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm
|
|||
}
|
||||
if (taken == 0) return IO_CLOSED;
|
||||
err = WSAGetLastError();
|
||||
if (err != WSAEWOULDBLOCK) return err;
|
||||
/* On Windows, and on UDP, a connreset simply means the
|
||||
* previous send failed. On TCP, it means our socket
|
||||
* is now useless, so the error must pass. I am
|
||||
* hoping waitfd will still get the error. */
|
||||
if (err != WSAEWOULDBLOCK && err != WSAECONNRESET) return err;
|
||||
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +275,11 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
|
|||
}
|
||||
if (taken == 0) return IO_CLOSED;
|
||||
err = WSAGetLastError();
|
||||
if (err != WSAEWOULDBLOCK) return err;
|
||||
/* On Windows, and on UDP, a connreset simply means the
|
||||
* previous send failed. On TCP, it means our socket
|
||||
* is now useless, so the error must pass. I am
|
||||
* hoping waitfd will still get the error. */
|
||||
if (err != WSAEWOULDBLOCK && err != WSAECONNRESET) return err;
|
||||
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue