fixes ssl shutdown

Mon, 26 Dec 2016 15:34:44 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 26 Dec 2016 15:34:44 +0100
changeset 128
288fd9b9a739
parent 127
84e206063b64
child 129
fd324464f56f

fixes ssl shutdown

src/server/daemon/sessionhandler.c file | annotate | diff | comparison | revisions
src/server/daemon/sessionhandler.h file | annotate | diff | comparison | revisions
--- a/src/server/daemon/sessionhandler.c	Mon Dec 26 14:00:10 2016 +0100
+++ b/src/server/daemon/sessionhandler.c	Mon Dec 26 15:34:44 2016 +0100
@@ -58,11 +58,19 @@
 }
 
 int connection_ssl_read(Connection *conn, void *buf, int len) {
-    return SSL_read(conn->ssl, buf, len);
+    int ret = SSL_read(conn->ssl, buf, len);
+    if(ret <= 0) {
+        conn->ssl_error = SSL_get_error();
+    }
+    return ret;
 }
 
 int connection_ssl_write(Connection *conn, const void *buf, int len) {
-    return SSL_write(conn->ssl, buf, len);
+    int ret = SSL_write(conn->ssl, buf, len);
+    if(ret <= 0) {
+        conn->ssl_error = SSL_get_error();
+    }
+    return ret;
 }
 
 void connection_ssl_close(Connection *conn) {
@@ -71,11 +79,10 @@
 }
 
 void connection_destroy(Connection *conn) {
+    conn->close(conn);
     if(conn->ssl) {
         SSL_free(conn->ssl);
     }
-    conn->close(conn);
-    
     free(conn);    
 }
 
--- a/src/server/daemon/sessionhandler.h	Mon Dec 26 14:00:10 2016 +0100
+++ b/src/server/daemon/sessionhandler.h	Mon Dec 26 15:34:44 2016 +0100
@@ -50,6 +50,7 @@
     HttpListener         *listener;
     SessionHandler       *session_handler;
     SSL                  *ssl;
+    long                 ssl_error;
     int (*read)(Connection *conn, void *buf, int len);
     int (*write)(Connection *conn, const void *buf, int len);
     void (*close)(Connection *conn);

mercurial