Download raw body.
httpd: remove MAX_IMSG_DATA_SIZE
Remove MAX_IMSG_DATA_SIZE and we avoid having to calculate the length
over and over again in a loop.
OK?
commit ab64b2726bed8f57259124a8aa04ba3dd5cdf98c
Author: Rafael Sadowski <rafael@sizeofvoid.org>
Date: Sat Oct 17 08:59:57 2026 +0200
httpd: remove MAX_IMSG_DATA_SIZE
diff --git a/config.c b/config.c
index 957da66..23a7042 100644
--- a/config.c
+++ b/config.c
@@ -320,7 +320,7 @@ config_settls(struct httpd *env, struct server *srv, enum tls_config_type type,
struct server_config *srv_conf = &srv->srv_conf;
struct tls_config tls;
struct iovec iov[2];
- size_t c;
+ size_t c, maxchunk;
if (data == NULL || len == 0)
return (0);
@@ -335,10 +335,13 @@ config_settls(struct httpd *env, struct server *srv, enum tls_config_type type,
tls.tls_len = len;
tls.tls_chunk_offset = 0;
+ /* largest chunk that fits next to the header into one imsg */
+ maxchunk = MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(tls);
+
while (len > 0) {
tls.tls_chunk_len = len;
- if (tls.tls_chunk_len > (MAX_IMSG_DATA_SIZE - sizeof(tls)))
- tls.tls_chunk_len = MAX_IMSG_DATA_SIZE - sizeof(tls);
+ if (tls.tls_chunk_len > maxchunk)
+ tls.tls_chunk_len = maxchunk;
c = 0;
iov[c].iov_base = &tls;
httpd: remove MAX_IMSG_DATA_SIZE