Fix intermittent Cygwin failures in s_client
authorRichard Levitte <levitte@openssl.org>
Sun, 14 Jan 2018 16:15:32 +0000 (17:15 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 15 Jan 2018 08:32:51 +0000 (09:32 +0100)
This was identified for Windows almost two years ago for VC and
msys/mingw.  It seems that Cygwin suffers from the same issue, and
since Cygwin doesn't define OPENSSL_SYS_WINDOWS, we need to make a
special case to have a 50ms pause before closing the TLS connection.

Ref: git commit cb2e10f257a464c6b475b321dd9e4769df84dbf6

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5074)

(cherry picked from commit 27da42d85212f80fc0db02b1cedf1d49fbfb8c43)

apps/s_client.c

index d1605454b9ebf2fdc4173ea7d27d34b1612e98ee..3b6606963d7c3eac0e89755b05f6f21fabcb2c6b 100644 (file)
@@ -2461,7 +2461,7 @@ 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
@@ -2469,8 +2469,12 @@ int s_client_main(int argc, char **argv)
      * 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