Skip to content

Commit 6b7f354

Browse files
Buffer optional uncork data after failure to flush already corked data
Co-authored-by: GetThatCookie <GetThatCookie@users.noreply.github.com>
1 parent 44247fe commit 6b7f354

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/AsyncSocket.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,17 @@ struct AsyncSocket {
347347
loopData->corkOffset = 0;
348348

349349
if (failed) {
350-
/* We do not need to care for buffering here, write does that */
350+
/* If corked data fails to flush, and we have more data to write, immediately buffer it here
351+
* since the above call to write excludes src */
352+
if (!optionally && src && length) {
353+
AsyncSocketData<SSL> *asyncSocketData = getAsyncSocketData();
354+
asyncSocketData->buffer.append(src, (size_t) length);
355+
356+
/* We wrote to per socket buffer, so report success */
357+
return {length, true};
358+
}
359+
360+
/* We do not need to care for buffering (of the corked data) here, write did that */
351361
return {0, true};
352362
}
353363
}

0 commit comments

Comments
 (0)