Browse code

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 authored on 09/07/2010 18:03:45
Showing 1 changed files
... ...
@@ -1151,9 +1151,15 @@ ssl_read_skipped:
1151 1151
 			}
1152 1152
 			goto end; /* no more data to read */
1153 1153
 		case SSL_ERROR_WANT_WRITE:
1154
-			/* write buffer too small, nothing written */
1154
+			if (wr.used) {
1155
+				/* something was written => buffer not big enough to hold
1156
+				   everything => reset buffer & retry (the tcp_write already
1157
+				   happened if we are here) */
1158
+				goto continue_ssl_read;
1159
+			}
1160
+			/* else write buffer too small, nothing written */
1155 1161
 			BUG("write buffer too small (%d/%d bytes)\n",
1156
-					wr.used, wr.size);
1162
+						wr.used, wr.size);
1157 1163
 			goto bug;
1158 1164
 		case SSL_ERROR_SSL:
1159 1165
 			/* protocol level error */