ssl zero return indicates shutdown

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-12-03 21:37:34 +08:00
parent 622d9f2ff3
commit 972eaf91a0

View file

@ -441,7 +441,11 @@ lws_ssl_capable_read(struct libwebsocket_context *context,
return lws_ssl_capable_read_no_ssl(context, wsi, buf, len);
n = SSL_read(wsi->ssl, buf, len);
if (n >= 0) {
/* manpage: returning 0 means connection shut down */
if (!n)
return LWS_SSL_CAPABLE_ERROR;
if (n > 0) {
/*
* if it was our buffer that limited what we read,
* check if SSL has additional data pending inside SSL buffers.
@ -490,7 +494,7 @@ lws_ssl_capable_write(struct libwebsocket *wsi, unsigned char *buf, int len)
return lws_ssl_capable_write_no_ssl(wsi, buf, len);
n = SSL_write(wsi->ssl, buf, len);
if (n >= 0)
if (n > 0)
return n;
n = SSL_get_error(wsi->ssl, n);