Update PR#3925
[oweals/openssl.git] / apps / s_time.c
index 998ef72b88224ea7ec441d823de713ede9b492b9..3c8efe9142f6e6b6e45afb00951fb594ca02470c 100644 (file)
@@ -234,8 +234,10 @@ int s_time_main(int argc, char **argv)
                                    fmt_http_get_cmd, www_path);
             if (SSL_write(scon, buf, buf_len) <= 0)
                 goto end;
-            while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)
-                bytes_read += i;
+            while ((i = SSL_read(scon, buf, sizeof(buf))) > 0 ||
+                        SSL_get_error(scon, i) == SSL_ERROR_WANT_READ ||
+                        SSL_get_error(scon, i) == SSL_ERROR_WANT_WRITE)
+                if (i > 0) bytes_read += i;
         }
 #ifdef NO_SHUTDOWN
         SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
@@ -292,7 +294,9 @@ int s_time_main(int argc, char **argv)
                                fmt_http_get_cmd, www_path);
         if (SSL_write(scon, buf, buf_len) <= 0)
             goto end;
-        while (SSL_read(scon, buf, sizeof(buf)) > 0)
+        while ((i = SSL_read(scon, buf, sizeof(buf))) > 0 ||
+                    SSL_get_error(scon, i) == SSL_ERROR_WANT_READ ||
+                    SSL_get_error(scon, i) == SSL_ERROR_WANT_WRITE)
             continue;
     }
 #ifdef NO_SHUTDOWN
@@ -323,8 +327,10 @@ int s_time_main(int argc, char **argv)
                          www_path);
             if (SSL_write(scon, buf, strlen(buf)) <= 0)
                 goto end;
-            while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)
-                bytes_read += i;
+            while ((i = SSL_read(scon, buf, sizeof(buf))) > 0 ||
+                        SSL_get_error(scon, i) == SSL_ERROR_WANT_READ ||
+                        SSL_get_error(scon, i) == SSL_ERROR_WANT_WRITE)
+                if (i > 0) bytes_read += i;
         }
 #ifdef NO_SHUTDOWN
         SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);