summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorcheatfate <ka@hardcore.kiev.ua>2016-09-07 12:19:06 +0300
committercheatfate <ka@hardcore.kiev.ua>2016-09-07 12:19:06 +0300
commit1350d5312b248128582db6d2ebde8d7ce5349e48 (patch)
tree1046b38d7b9b566edc9b2813affe2e25214cadfd /lib/pure
parent08a6f3fc67f1bac78c47a241c94f936d7fbd5108 (diff)
downloadNim-1350d5312b248128582db6d2ebde8d7ce5349e48.tar.gz
Removed tests with `asyncio`.
Fix ssl connection drop in asyncnet
Add tasyncssl test
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/asyncnet.nim11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim
index dbf895d18..334f95baa 100644
--- a/lib/pure/asyncnet.nim
+++ b/lib/pure/asyncnet.nim
@@ -165,9 +165,14 @@ when defineSsl:
       await sendPendingSslData(socket, flags)
     of SSL_ERROR_WANT_READ:
       var data = await recv(socket.fd.AsyncFD, BufferSize, flags)
-      let ret = bioWrite(socket.bioIn, addr data[0], data.len.cint)
-      if ret < 0:
-        raiseSSLError()
+      let length = len(data)
+      if length > 0:
+        let ret = bioWrite(socket.bioIn, addr data[0], data.len.cint)
+        if ret < 0:
+          raiseSSLError()
+      elif length == 0:
+        # connection not properly closed by remote side or connection dropped
+        SSL_set_shutdown(socket.sslHandle, SSL_RECEIVED_SHUTDOWN)
     else:
       raiseSSLError("Cannot appease SSL.")