]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "Revert "Revert "io.sockets.secure.openssl: undo some error handling that...
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 27 Dec 2021 17:11:05 +0000 (11:11 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 27 Dec 2021 17:11:05 +0000 (11:11 -0600)
This reverts commit dad02fe74d8bea7d8782ada82c872e5f79228b4d.

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

index 9c1a9b51fe49bbdb749a84c7be51a001709c274e..d88c4fd8bb374b693c969349d5868237368e114c 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