diff options
author | Andy Polyakov <appro@openssl.org> | 2018-04-05 19:19:35 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2018-04-08 11:42:35 +0200 |
commit | f69d050ee344e931aea4102f09bb0134a4f4c12a (patch) | |
tree | 3013d239bb214e4bfd9f7dfe398cb4d60bb9193c /apps | |
parent | dcf3d83faf3542b984d5586bdb1d50c90137a29d (diff) |
apps/{s_client.c|s_socket}.c: omit usleep calls.
Even though removed calls were oiriginally added on Windows, problem
they tried to mitigate is not Windows-specific.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5887)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/s_client.c | 26 | ||||
-rw-r--r-- | apps/s_socket.c | 13 |
2 files changed, 13 insertions, 26 deletions
diff --git a/apps/s_client.c b/apps/s_client.c index ce7366f8fe..89cddb30f8 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -3051,19 +3051,6 @@ int s_client_main(int argc, char **argv) do_ssl_shutdown(con); /* - * Give the socket time to send its last data before we close it. - * No amount of setting SO_LINGER etc on the socket seems to persuade - * Windows to send the data before closing the socket...but sleeping - * for a short time seems to do it (units in ms) - * TODO: Find a better way to do this - */ -#if defined(OPENSSL_SYS_WINDOWS) - Sleep(50); -#elif defined(OPENSSL_SYS_CYGWIN) - usleep(50000); -#endif - - /* * If we ended with an alert being sent, but still with data in the * network buffer to be read, then calling BIO_closesocket() will * result in a TCP-RST being sent. On some platforms (notably @@ -3074,6 +3061,19 @@ int s_client_main(int argc, char **argv) * TCP-RST. This seems to allow the peer to read the alert data. */ shutdown(SSL_get_fd(con), 1); /* SHUT_WR */ + /* + * We just said we have nothing else to say, but it doesn't mean that + * the other side has nothing. It's even recommended to consume incoming + * data. [In testing context this ensures that alerts are passed on...] + */ + timeout.tv_sec = 0; + timeout.tv_usec = 500000; /* some extreme round-trip */ + do { + FD_ZERO(&readfds); + openssl_fdset(s, &readfds); + } while (select(s + 1, &readfds, NULL, NULL, &timeout) > 0 + && BIO_read(sbio, sbuf, BUFSIZZ) > 0); + BIO_closesocket(SSL_get_fd(con)); end: if (con != NULL) { diff --git a/apps/s_socket.c b/apps/s_socket.c index 80b63ebc4d..ae62a135ce 100644 --- a/apps/s_socket.c +++ b/apps/s_socket.c @@ -334,19 +334,6 @@ int do_server(int *accept_sock, const char *host, const char *port, i = (*cb)(sock, type, protocol, context); /* - * Give the socket time to send its last data before we close it. - * No amount of setting SO_LINGER etc on the socket seems to - * persuade Windows to send the data before closing the socket... - * but sleeping for a short time seems to do it (units in ms) - * TODO: Find a better way to do this - */ -#if defined(OPENSSL_SYS_WINDOWS) - Sleep(50); -#elif defined(OPENSSL_SYS_CYGWIN) - usleep(50000); -#endif - - /* * If we ended with an alert being sent, but still with data in the * network buffer to be read, then calling BIO_closesocket() will * result in a TCP-RST being sent. On some platforms (notably |