Skip to content

Instantly share code, notes, and snippets.

@bagder
Created April 7, 2020 09:16
Show Gist options
  • Select an option

  • Save bagder/ef6c09eb00af7231a9bd72f695af2dbb to your computer and use it in GitHub Desktop.

Select an option

Save bagder/ef6c09eb00af7231a9bd72f695af2dbb to your computer and use it in GitHub Desktop.
take two for 4919
From 0376e727e813a76ddd034d23bfe6b9ee4fece452 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Mon, 6 Apr 2020 00:02:13 +0200
Subject: [PATCH] http: fix EAGAIN handling when sending huge request
---
lib/http.c | 2 +-
lib/transfer.c | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/http.c b/lib/http.c
index bff3adc17..d59a47af8 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1287,11 +1287,11 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer **inp,
http->postdata = ptr;
http->postsize = (curl_off_t)size;
http->send_buffer = in;
http->sending = HTTPSEND_REQUEST;
-
+ DEBUGF(infof(data, "Couldn't send the whole request at once\n"));
return CURLE_OK;
}
http->sending = HTTPSEND_BODY;
/* the full buffer was sent, clean up and return */
}
diff --git a/lib/transfer.c b/lib/transfer.c
index 27c984f8f..3b387902e 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1835,14 +1835,17 @@ Curl_setup_transfer(
the same we read from. -1 disables */
)
{
struct SingleRequest *k = &data->req;
struct connectdata *conn = data->conn;
+ struct HTTP *http = data->req.protop;
DEBUGASSERT(conn != NULL);
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
- if(conn->bits.multiplex || conn->httpversion == 20) {
+ if(conn->bits.multiplex || conn->httpversion == 20 ||
+ ((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
+ http->sending == HTTPSEND_REQUEST)) {
/* when multiplexing, the read/write sockets need to be the same! */
conn->sockfd = sockindex == -1 ?
((writesockindex == -1 ? CURL_SOCKET_BAD : conn->sock[writesockindex])) :
conn->sock[sockindex];
conn->writesockfd = conn->sockfd;
@@ -1871,11 +1874,10 @@ Curl_setup_transfer(
if(sockindex != -1)
k->keepon |= KEEP_RECV;
if(writesockindex != -1) {
- struct HTTP *http = data->req.protop;
/* HTTP 1.1 magic:
Even if we require a 100-return code before uploading data, we might
need to write data before that since the REQUEST may not have been
finished sent off just yet.
--
2.21.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment