diff options
author | Daniel Jelinski <daniel.jelinski@thomsonreuters.com> | 2018-07-19 14:07:59 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-07-24 11:15:31 +0300 |
commit | 27bdfb3f7be0fdba0a9f0a3b8db319280934fd5b (patch) | |
tree | 7c2cb3b7931ed48f235142edfcea00f44e862199 | |
parent | 6f5ef24f068a86d0f61ce39f674462128c1743d1 (diff) | |
download | curl-27bdfb3f7be0fdba0a9f0a3b8db319280934fd5b.tar.gz |
windows: implement send buffer tuningJelinski/buffer-tuning-under-Windows
Bug: https://curl.haxx.se/mail/lib-2018-07/0080.html
-rw-r--r-- | lib/transfer.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index 435d3e1ec..de1c08a1d 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -869,6 +869,25 @@ static CURLcode done_sending(struct connectdata *conn, return CURLE_OK; } +#ifdef WIN32 +#ifndef SIO_IDEAL_SEND_BACKLOG_QUERY +#define SIO_IDEAL_SEND_BACKLOG_QUERY 0x4004747B +#endif +static void win_update_buffer_size(curl_socket_t sockfd) +{ + int result; + ULONG ideal; + DWORD ideallen; + result = WSAIoctl(sockfd, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0, + &ideal, sizeof(ideal), &ideallen, 0, 0); + if(result == 0) { + setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, + (const char *)&ideal, sizeof(ideal)); + } +} +#else +#define win_update_buffer_size(x) +#endif /* * Send data to upload to the server, when the socket is writable. @@ -1020,10 +1039,11 @@ static CURLcode readwrite_upload(struct Curl_easy *data, k->upload_fromhere, /* buffer pointer */ k->upload_present, /* buffer size */ &bytes_written); /* actually sent */ - if(result) return result; + win_update_buffer_size(conn->writesockfd); + if(data->set.verbose) /* show the data before we change the pointer upload_fromhere */ Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere, |