]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "io.sockets.secure.openssl: undo some error handling that makes factorcode...
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 27 Dec 2021 16:24:37 +0000 (08:24 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 27 Dec 2021 16:24:37 +0000 (08:24 -0800)
This reverts commit 41276b77f381a57a0b4110a92380e666769950f6.

basis/io/sockets/secure/openssl/openssl.factor

index fd0c4207b7411e83ceaa383ef7fe46dc897d8f53..8f55e3008c1370beb290ba60f923e0ffe1d14c8e 100644 (file)
@@ -187,7 +187,7 @@ M: openssl-context dispose*
         tri
     ] with-destructors ;
 
-TUPLE: ssl-handle < disposable file handle connected ;
+TUPLE: ssl-handle < disposable file handle connected terminated ;
 
 SYMBOL: default-secure-context
 
@@ -275,7 +275,8 @@ PRIVATE>
     handle ;
 
 : ssl-error-syscall ( ssl-handle -- event/f )
-    f >>connected drop
+    f >>connected
+    t >>terminated drop
     ERR_get_error {
         { -1 [
             errno { [ ECONNRESET = ] [ EPIPE = ] } 1||
@@ -296,7 +297,7 @@ PRIVATE>
         { SSL_ERROR_SSL [ drop throw-ssl-error ] }
         ! https://stackoverflow.com/questions/50223224/ssl-read-returns-ssl-error-zero-return-but-err-get-error-is-0
         ! we got disconnected
-        { SSL_ERROR_ZERO_RETURN [ drop f ] }
+        { SSL_ERROR_ZERO_RETURN [ t >>terminated f >>connected drop f ] }
         { SSL_ERROR_WANT_ACCEPT [ drop +input+ ] }
     } case ;
 
@@ -310,8 +311,12 @@ PRIVATE>
 
 : maybe-handshake ( ssl-handle -- )
     dup connected>> [ drop ] [
-        [ [ do-ssl-accept ] with-timeout ]
-        [ t swap connected<< ] bi
+        dup terminated>> [
+            drop
+        ] [
+            [ [ do-ssl-accept ] with-timeout ]
+            [ t swap connected<< ] bi
+        ] if
     ] if ;
 
 ! Input ports