Skip to content

CivetWeb HTTP Sample - reduce RAM usage #28376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions samples/net/sockets/civetweb/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions samples/net/sockets/civetweb/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down