diff --git a/src/stream/read.c b/src/stream/read.c
index 2555655..9b697f5 100644
--- a/src/stream/read.c
+++ b/src/stream/read.c
@@ -20,12 +20,11 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
-#include
-
#include "stream.h"
#include "logger.h"
@@ -67,7 +66,7 @@ streamRead(Stream this, void * buf, size_t count)
case STREAM_SSL:
done = SSL_read((this->handle).ssl, buf, count);
- if (0 > done) {
+ if (0 >= done) {
switch (SSL_get_error((this->handle).ssl, done)) {
case SSL_ERROR_SSL:
case SSL_ERROR_SYSCALL:
diff --git a/src/stream/write.c b/src/stream/write.c
index 5e9b346..f8e5899 100644
--- a/src/stream/write.c
+++ b/src/stream/write.c
@@ -20,11 +20,16 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
#include "stream.h"
+#include "logger.h"
+
+extern Logger logger;
+
ssize_t
streamWrite(Stream this, void * buf, size_t count)
@@ -59,6 +64,29 @@ streamWrite(Stream this, void * buf, size_t count)
case STREAM_SSL:
done = SSL_write((this->handle).ssl, buf, count);
+
+ if (0 >= done) {
+ switch (SSL_get_error((this->handle).ssl, done)) {
+ case SSL_ERROR_SSL:
+ case SSL_ERROR_SYSCALL:
+ {
+ unsigned long err;
+
+ while (0 != (err = ERR_get_error())) {
+ loggerLog(
+ logger,
+ LOGGER_DEBUG,
+ ERR_error_string(err, NULL));
+ }
+ }
+ // DROP THROUGH
+
+ case SSL_ERROR_ZERO_RETURN:
+ done = -2;
+ break;
+ }
+ }
+
break;
default: