summaryrefslogtreecommitdiff
path: root/lib/smtp.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2022-06-06 13:02:30 -0400
committerDaniel Stenberg <daniel@haxx.se>2022-06-20 09:42:40 +0200
commit7f43f3dc5994d01b12eb1dfe2ebf5e8371b4e32b (patch)
tree3cfe172d70989c32bd3f4efa239100f1bbf3ebaf /lib/smtp.c
parentaea8ac14df03732e16d2dd98fa0924ed96183812 (diff)
downloadcurl-7f43f3dc5994d01b12eb1dfe2ebf5e8371b4e32b.tar.gz
transfer: upload performance; avoid tiny send
Append to the upload buffer when only small amount remains in buffer rather than performing a separate tiny send to empty buffer. Avoid degenerative upload behavior which might cause curl to send mostly 1-byte DATA frames after exhausing the h2 send window size Related discussion: https://github.com/nghttp2/nghttp2/issues/1722 Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com> Closes #8965
Diffstat (limited to 'lib/smtp.c')
-rw-r--r--lib/smtp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index e8ff2576f..6ebb41af6 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -1820,7 +1820,9 @@ static CURLcode smtp_parse_address(struct Curl_easy *data, const char *fqma,
return result;
}
-CURLcode Curl_smtp_escape_eob(struct Curl_easy *data, const ssize_t nread)
+CURLcode Curl_smtp_escape_eob(struct Curl_easy *data,
+ const ssize_t nread,
+ const ssize_t offset)
{
/* When sending a SMTP payload we must detect CRLF. sequences making sure
they are sent as CRLF.. instead, as a . on the beginning of a line will
@@ -1854,7 +1856,9 @@ CURLcode Curl_smtp_escape_eob(struct Curl_easy *data, const ssize_t nread)
/* This loop can be improved by some kind of Boyer-Moore style of
approach but that is saved for later... */
- for(i = 0, si = 0; i < nread; i++) {
+ if(offset)
+ memcpy(scratch, data->req.upload_fromhere, offset);
+ for(i = offset, si = offset; i < nread; i++) {
if(SMTP_EOB[smtp->eob] == data->req.upload_fromhere[i]) {
smtp->eob++;