Add EVP_MD_CTX_ctrl function.
[openssl.git] / apps / s_server.c
index 6b6035f0ba14c8682d4cfc49723c6cafcedd48fa..fd8035de9902242d1ebabdecf76c88123ee72622 100644 (file)
@@ -194,7 +194,6 @@ typedef unsigned int u_int;
 static RSA *tmp_rsa_cb(SSL *s, int is_export, int keylength);
 #endif
 static int not_resumable_sess_cb(SSL *s, int is_forward_secure);
-static void wait_for_async(SSL *s);
 static int sv_body(char *hostname, int s, int stype, unsigned char *context);
 static int www_body(char *hostname, int s, int stype, unsigned char *context);
 static int rev_body(char *hostname, int s, int stype, unsigned char *context);
@@ -1661,7 +1660,7 @@ int s_server_main(int argc, char *argv[])
 
     if (async) {
         SSL_CTX_set_mode(ctx, SSL_MODE_ASYNC);
-        ASYNC_init_pool(0, 0);
+        ASYNC_init(1, 0, 0);
     }
 
 #ifndef OPENSSL_NO_SRTP
@@ -1975,7 +1974,7 @@ int s_server_main(int argc, char *argv[])
     BIO_free(bio_s_msg);
     bio_s_msg = NULL;
     if (async) {
-        ASYNC_free_pool();
+        ASYNC_cleanup(1);
     }
     return (ret);
 }
@@ -2008,21 +2007,6 @@ static void print_stats(BIO *bio, SSL_CTX *ssl_ctx)
                SSL_CTX_sess_get_cache_size(ssl_ctx));
 }
 
-static void wait_for_async(SSL *s)
-{
-    int width, fd;
-    fd_set asyncfds;
-
-    fd = SSL_get_async_wait_fd(s);
-    if (!fd)
-        return;
-
-    width = fd + 1;
-    FD_ZERO(&asyncfds);
-    openssl_fdset(fd, &asyncfds);
-    select(width, (void *)&asyncfds, NULL, NULL, NULL);
-}
-
 static int sv_body(char *hostname, int s, int stype, unsigned char *context)
 {
     char *buf = NULL;
@@ -2152,7 +2136,8 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
         int read_from_sslcon;
 
         read_from_terminal = 0;
-        read_from_sslcon = SSL_pending(con);
+        read_from_sslcon = SSL_pending(con)
+                           || (async && SSL_waiting_for_async(con));
 
         if (!read_from_sslcon) {
             FD_ZERO(&readfds);
@@ -2348,7 +2333,13 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
             }
         }
         if (read_from_sslcon) {
-            if (!SSL_is_init_finished(con)) {
+            /*
+             * init_ssl_connection handles all async events itself so if we're
+             * waiting for async then we shouldn't go back into
+             * init_ssl_connection
+             */
+            if ((!async || !SSL_waiting_for_async(con))
+                    && !SSL_is_init_finished(con)) {
                 i = init_ssl_connection(con);
 
                 if (i < 0) {