Skip to content
Snippets Groups Projects
Commit 7a5eafd4 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

SSL.sslfile: Write multiple packets in the same write().

Use the support for writev(2) to write the packets in the write_buffer.

This should improve data throughput measurably.

NB: This reduces the number of required rounds in the backend
during handshaking to the old level.
parent 4d918b61
No related branches found
No related tags found
No related merge requests found
...@@ -2066,14 +2066,13 @@ protected int ssl_write_callback (int called_from_real_backend) ...@@ -2066,14 +2066,13 @@ protected int ssl_write_callback (int called_from_real_backend)
write_to_stream: write_to_stream:
do { do {
if (sizeof (write_buffer)) { if (sizeof (write_buffer)) {
string output = write_buffer[0];
int written; int written;
#ifdef SIMULATE_CLOSE_PACKET_WRITE_FAILURE #ifdef SIMULATE_CLOSE_PACKET_WRITE_FAILURE
if (conn->state & CONNECTION_local_closing) if (conn->state & CONNECTION_local_closing)
written = -1; written = -1;
else else
#endif #endif
written = stream->write (output); written = stream->write (write_buffer);
if (written < 0 if (written < 0
#if 0 #if 0
...@@ -2148,10 +2147,16 @@ protected int ssl_write_callback (int called_from_real_backend) ...@@ -2148,10 +2147,16 @@ protected int ssl_write_callback (int called_from_real_backend)
break write_to_stream; break write_to_stream;
} }
if (written == sizeof (output)) for (int bytes = written; bytes > 0;) {
if (bytes >= sizeof(write_buffer[0])) {
bytes -= sizeof(write_buffer[0]);
write_buffer = write_buffer[1..]; write_buffer = write_buffer[1..];
else } else {
write_buffer[0] = output[written..]; write_buffer[0] = write_buffer[0][bytes..];
bytes = 0;
break;
}
}
SSL3_DEBUG_MSG ("ssl_write_callback: Wrote %d bytes (%d strings left)\n", SSL3_DEBUG_MSG ("ssl_write_callback: Wrote %d bytes (%d strings left)\n",
written, sizeof (write_buffer)); written, sizeof (write_buffer));
......
...@@ -447,7 +447,7 @@ test_do([[ ...@@ -447,7 +447,7 @@ test_do([[
int state; int state;
int trigged = 20; int trigged = 10;
string fail; string fail;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment