Skip to content

Commit 1b04573

Browse files
committed
lib/tls: may need to send in receive loop
The engine can signal us that it needs to send some data (especially connection aborts), and we should be responsive to that request rather than spinning to timeout (or forever, perhaps) for an event that's not coming.
1 parent 51c93ba commit 1b04573

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/tls/tls.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,23 @@ namespace
295295
{
296296
return -ENOTCONN;
297297
}
298+
299+
if ((state & BR_SSL_SENDREC) == BR_SSL_SENDREC)
300+
{
301+
// If we need to send records, send them first.
302+
auto [sent, unfinished] = send_records(t, connection);
303+
if (sent == -ECOMPARTMENTFAIL)
304+
{
305+
// The TCP/IP stack crashed; tell the
306+
// caller that the link is dead.
307+
return -ENOTCONN;
308+
}
309+
if (sent <= 0)
310+
{
311+
return sent;
312+
}
313+
}
314+
298315
if ((state & BR_SSL_RECVAPP) == BR_SSL_RECVAPP)
299316
{
300317
// If there are data ready to receive, return

0 commit comments

Comments
 (0)