fixes keep-alive with ssl

Sun, 14 Jan 2018 10:38:09 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 14 Jan 2018 10:38:09 +0100
changeset 194
6345f50208d5
parent 193
aa8393527b1e
child 195
d367b687bc74

fixes keep-alive with ssl

src/server/daemon/httplistener.c file | annotate | diff | comparison | revisions
src/server/daemon/sessionhandler.c file | annotate | diff | comparison | revisions
src/server/daemon/sessionhandler.h file | annotate | diff | comparison | revisions
--- a/src/server/daemon/httplistener.c	Sat Jan 13 19:01:00 2018 +0100
+++ b/src/server/daemon/httplistener.c	Sun Jan 14 10:38:09 2018 +0100
@@ -402,6 +402,7 @@
         conn->address = ca;
         conn->fd = clientfd;
         conn->listener = ls;
+        conn->ssl_accepted = 0;
         if(ls->ssl) {
             // SSL connections are always non-blocking 
             // set socket non blocking
--- a/src/server/daemon/sessionhandler.c	Sat Jan 13 19:01:00 2018 +0100
+++ b/src/server/daemon/sessionhandler.c	Sun Jan 14 10:38:09 2018 +0100
@@ -260,7 +260,7 @@
     
     Event *event = malloc(sizeof(Event));
     ZERO(event, sizeof(Event));
-    event->fn = conn->ssl ? evt_request_ssl_accept : evt_request_input;
+    event->fn = conn->ssl && !conn->ssl_accepted ? evt_request_ssl_accept : evt_request_input;
     event->finish = evt_request_finish;
     event->cookie = io;
     
@@ -305,6 +305,7 @@
             return 0;
         }
     }
+    conn->ssl_accepted = WS_TRUE;
     
     // SSL_accept successful, start request input now
     event->fn = evt_request_input;
--- a/src/server/daemon/sessionhandler.h	Sat Jan 13 19:01:00 2018 +0100
+++ b/src/server/daemon/sessionhandler.h	Sun Jan 14 10:38:09 2018 +0100
@@ -51,6 +51,7 @@
     HttpListener         *listener;
     SessionHandler       *session_handler;
     SSL                  *ssl;
+    WSBool               ssl_accepted;
     int                  ssl_error;
     int (*read)(Connection *conn, void *buf, int len);
     int (*write)(Connection *conn, const void *buf, int len);

mercurial