Fixes SSL implementation of sendAsync.

This commit is contained in:
Dominik Picheta 2012-12-08 19:27:00 +00:00
commit 63112696b0

View file

@ -1329,14 +1329,14 @@ proc sendAsync*(socket: TSocket, data: string): int {.tags: [FWriteIO].} =
when defined(ssl): when defined(ssl):
if socket.isSSL: if socket.isSSL:
if result <= 0: if result <= 0:
let ret = SSLGetError(socket.sslHandle, bytesSent.cint) let ret = SSLGetError(socket.sslHandle, result.cint)
case ret case ret
of SSL_ERROR_ZERO_RETURN: of SSL_ERROR_ZERO_RETURN:
SSLError("TLS/SSL connection failed to initiate, socket closed prematurely.") SSLError("TLS/SSL connection failed to initiate, socket closed prematurely.")
of SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT: of SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT:
SSLError("Unexpected error occured.") # This should just not happen. SSLError("Unexpected error occured.") # This should just not happen.
of SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_READ: of SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_READ:
return false return 0
of SSL_ERROR_WANT_X509_LOOKUP: of SSL_ERROR_WANT_X509_LOOKUP:
SSLError("Function for x509 lookup has been called.") SSLError("Function for x509 lookup has been called.")
of SSL_ERROR_SYSCALL, SSL_ERROR_SSL: of SSL_ERROR_SYSCALL, SSL_ERROR_SSL: