From 2092095724003c315560e40388f91e644fe357f5 Mon Sep 17 00:00:00 2001 From: Alexander Kozhinov Date: Mon, 14 Sep 2020 23:43:39 +0200 Subject: [PATCH] samples: net: civetweb: reduce RAM usage adjust configuration so that civetweb uses less memory fixes #21179 Signed-off-by: Alexander Kozhinov --- samples/net/sockets/civetweb/prj.conf | 12 ++++++------ samples/net/sockets/civetweb/src/main.c | 14 ++++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/samples/net/sockets/civetweb/prj.conf b/samples/net/sockets/civetweb/prj.conf index e8a518e0d324..c06f8d8000b6 100644 --- a/samples/net/sockets/civetweb/prj.conf +++ b/samples/net/sockets/civetweb/prj.conf @@ -13,12 +13,12 @@ CONFIG_NET_IPV4=y # CONFIG_NET_IPV6 is not set CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y -CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=131072 -CONFIG_NET_TX_STACK_SIZE=8192 -CONFIG_NET_RX_STACK_SIZE=8192 -CONFIG_ISR_STACK_SIZE=8192 -CONFIG_MAIN_STACK_SIZE=8192 -CONFIG_IDLE_STACK_SIZE=2048 +CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=16384 +CONFIG_NET_TX_STACK_SIZE=2048 +CONFIG_NET_RX_STACK_SIZE=2048 +CONFIG_ISR_STACK_SIZE=2048 +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_IDLE_STACK_SIZE=1024 CONFIG_DNS_RESOLVER=y diff --git a/samples/net/sockets/civetweb/src/main.c b/samples/net/sockets/civetweb/src/main.c index f36db1449af4..d50d299aa765 100644 --- a/samples/net/sockets/civetweb/src/main.c +++ b/samples/net/sockets/civetweb/src/main.c @@ -10,7 +10,13 @@ #include "civetweb.h" -#define CIVETWEB_MAIN_THREAD_STACK_SIZE 4096 +#define HTTP_PORT 8080 +#define HTTPS_PORT 4443 + +#define CIVETWEB_MAIN_THREAD_STACK_SIZE CONFIG_MAIN_STACK_SIZE + +/* Use samllest possible value of 1024 (see the line 18619 of civetweb.c) */ +#define MAX_REQUEST_SIZE_BYTES 1024 K_THREAD_STACK_DEFINE(civetweb_stack, CIVETWEB_MAIN_THREAD_STACK_SIZE); @@ -139,12 +145,12 @@ void *main_pthread(void *arg) { static const char * const options[] = { "listening_ports", - "8080", + STRINGIFY(HTTP_PORT), "num_threads", "1", "max_request_size", - "2048", - 0 + STRINGIFY(MAX_REQUEST_SIZE_BYTES), + NULL }; struct mg_callbacks callbacks;