commit e5da8f1a514bbd60c7622a3465611fbca305ace0
parent f27f2fd061cb3b86cb48c972a217d06ee72ccd3e
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 3 Aug 2026 21:13:38 +0200
avoid excessive memmove on larger uploads
Diffstat:
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/backend/paivana-httpd_reverse.c b/src/backend/paivana-httpd_reverse.c
@@ -226,11 +226,19 @@ struct HttpRequest
char *io_buf;
/**
- * Number of bytes already in the IO buffer.
+ * Number of bytes still to be sent from the IO buffer (upload
+ * phase), or number of bytes already in the IO buffer (while the
+ * client body is still being received).
*/
size_t io_len;
/**
+ * Read cursor into `io_buf` for the upload-to-curl phase: the next
+ * byte to hand to libcurl is `io_buf[io_off]`.
+ */
+ size_t io_off;
+
+ /**
* Number of bytes allocated for the IO buffer.
*/
unsigned int io_size;
@@ -774,12 +782,9 @@ curl_upload_cb (void *buf,
to_copy = GNUNET_MIN (hr->io_len,
len);
GNUNET_memcpy (buf,
- hr->io_buf,
+ &hr->io_buf[hr->io_off],
to_copy);
- /* shift remaining data back to the beginning of the buffer. */
- memmove (hr->io_buf,
- &hr->io_buf[to_copy],
- hr->io_len - to_copy);
+ hr->io_off += to_copy;
hr->io_len -= to_copy;
if (0 == hr->io_len)
{