diff options
author | Matt Caswell <matt@openssl.org> | 2016-05-20 16:34:24 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-27 15:18:54 +0100 |
commit | cb2e10f257a464c6b475b321dd9e4769df84dbf6 (patch) | |
tree | c0e84dd30b117421070d89ccaff773ea26818789 /apps | |
parent | 75dd6c1a39c4e73de7d8d782adb7008645248f50 (diff) |
Fix intermittent windows failures in TLSProxy tests
When closing down the socket in s_client Windows will close it immediately
even if there is data in the write buffer still waiting to be sent. This
was causing tests to fail in Msys/Mingw builds because TLSProxy doesn't see
the final CloseNotify.
I have experimented with various ways of doing this "properly" (e.g.
shutting down the socket before closing, setting SO_LINGER etc). I can't
seem to find the "magic" formula that will make Windows do this. Inserting
a short 50ms sleep seems to do the trick...but its not very "nice" so I've
inserted a TODO on this item. Perhaps someone else will have better luck
in figuring this out.
RT#4255
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/s_client.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/apps/s_client.c b/apps/s_client.c index fab5a5d807..4b9880ab99 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2402,6 +2402,16 @@ int s_client_main(int argc, char **argv) if (in_init) print_stuff(bio_c_out, con, full_log); do_ssl_shutdown(con); +#if defined(OPENSSL_SYS_WINDOWS) + /* + * 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 + */ + Sleep(50); +#endif BIO_closesocket(SSL_get_fd(con)); end: if (con != NULL) { |