fix(fetch/s3) Handle backpressure when upload large bodies (#20481)

Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
This commit is contained in:
Ciro Spaciari
2025-06-27 20:52:46 -07:00
committed by GitHub
parent 694a820a34
commit 964f2a8941
68 changed files with 4130 additions and 3548 deletions

View File

@@ -247,7 +247,7 @@ public:
int max_flush_len = std::min(buffer_len, (size_t)INT_MAX);
/* Attempt to write data to the socket */
int written = us_socket_write(SSL, (us_socket_t *) this, asyncSocketData->buffer.data(), max_flush_len, 0);
int written = us_socket_write(SSL, (us_socket_t *) this, asyncSocketData->buffer.data(), max_flush_len);
total_written += written;
/* Check if we couldn't write the entire buffer */
@@ -297,7 +297,7 @@ public:
int max_flush_len = std::min(buffer_len, (size_t)INT_MAX);
/* Write off as much as we can */
int written = us_socket_write(SSL, (us_socket_t *) this, asyncSocketData->buffer.data(), max_flush_len, /*nextLength != 0 | */length);
int written = us_socket_write(SSL, (us_socket_t *) this, asyncSocketData->buffer.data(), max_flush_len);
/* On failure return, otherwise continue down the function */
if ((unsigned int) written < buffer_len) {
/* Update buffering (todo: we can do better here if we keep track of what happens to this guy later on) */
@@ -342,7 +342,7 @@ public:
}
} else {
/* We are not corked */
int written = us_socket_write(SSL, (us_socket_t *) this, src, length, nextLength != 0);
int written = us_socket_write(SSL, (us_socket_t *) this, src, length);
/* Did we fail? */
if (written < length) {

View File

@@ -383,7 +383,7 @@ private:
httpContextData->onClientError(SSL, s, result.parserError, data, length);
}
/* For errors, we only deliver them "at most once". We don't care if they get halfways delivered or not. */
us_socket_write(SSL, s, httpErrorResponses[httpErrorStatusCode].data(), (int) httpErrorResponses[httpErrorStatusCode].length(), false);
us_socket_write(SSL, s, httpErrorResponses[httpErrorStatusCode].data(), (int) httpErrorResponses[httpErrorStatusCode].length());
us_socket_shutdown(SSL, s);
/* Close any socket on HTTP errors */
us_socket_close(SSL, s, 0, nullptr);