Browse Source

tls: partial SSL_write support when reading (tls_read_f)

When writing-on-read (due to queued send data waiting for a
renegotiation to complete), retry the write if it did not have
enough buffer space to complete (after freeing the buffer space by
 tcp_send-ing its content).
Andrei Pelinescu-Onciul 15 years ago
parent
commit
813284bad2
1 changed files with 8 additions and 2 deletions
  1. 8 2
      modules/tls/tls_server.c

+ 8 - 2
modules/tls/tls_server.c

@@ -1151,9 +1151,15 @@ ssl_read_skipped:
 			}
 			goto end; /* no more data to read */
 		case SSL_ERROR_WANT_WRITE:
-			/* write buffer too small, nothing written */
+			if (wr.used) {
+				/* something was written => buffer not big enough to hold
+				   everything => reset buffer & retry (the tcp_write already
+				   happened if we are here) */
+				goto continue_ssl_read;
+			}
+			/* else write buffer too small, nothing written */
 			BUG("write buffer too small (%d/%d bytes)\n",
-					wr.used, wr.size);
+						wr.used, wr.size);
 			goto bug;
 		case SSL_ERROR_SSL:
 			/* protocol level error */