diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 58ae8a264..015943ee6 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -271,8 +271,10 @@ static int ha_ssl_write(BIO *h, const char *buf, int num)
 	tmpbuf.data = num;
 	tmpbuf.head = 0;
 	ret = ctx->xprt->snd_buf(ctx->conn, ctx->xprt_ctx, &tmpbuf, num, 0);
-	if (ret == 0 && !(ctx->conn->flags & CO_FL_ERROR))
+	if (ret == 0 && !(ctx->conn->flags & CO_FL_ERROR)) {
 		BIO_set_retry_write(h);
+		ret = -1;
+	}
 	return ret;
 }
 
@@ -304,8 +306,10 @@ static int ha_ssl_read(BIO *h, char *buf, int size)
 	tmpbuf.data = 0;
 	tmpbuf.head = 0;
 	ret = ctx->xprt->rcv_buf(ctx->conn, ctx->xprt_ctx, &tmpbuf, size, 0);
-	if (ret == 0 && !(ctx->conn->flags & CO_FL_ERROR))
+	if (ret == 0 && !(ctx->conn->flags & CO_FL_ERROR)) {
 		BIO_set_retry_read(h);
+		ret = -1;
+	}
 
 	return ret;
 }