Merge pull request #4733 from cheatfate/asyncssl_and_tests

async: small ssl fix and updated tests
This commit is contained in:
Andreas Rumpf 2016-09-08 08:57:47 +02:00 • committed by GitHub
commit 1f6b2c4d11
5 changed files with 75 additions and 174 deletions

View file

@ -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.")