1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

expose compiletime constants to setting from configure

This patch allows control of the main compiletime constants in libwebsockets
from the configure commandline.

README is updated with documentation on what's available, how to set them
and the defaults.

The constants are logged with "info" severity (not visible by default) at
context create time.

The zlib constant previously exposed like this is moved to private-libwebsockets.h
so it can be printed along with the rest.

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-01-12 23:42:17 +08:00
parent d678ea3cd2
commit c0d6b63c83
4 changed files with 92 additions and 4 deletions

View file

@ -81,6 +81,50 @@ args throgh CFLAGS, eg
They all have defaults so you only need to take care about them if you want
to tune them to the amount of memory available.
- FD_HASHTABLE_MODULUS default 32: size of the file descriptor hash map,
affects server performance with large numbers of connections, at the cost of
increased memory consumption
- MAX_CLIENTS default 100: total number of simultaneous connections
allowed... reserves some memory even when not in use, so reduce for embedded
applications that only expect one or two connections
- LWS_MAX_HEADER_NAME_LENGTH default 64: max characters in an HTTP header
name that libwebsockets can cope with
- LWS_MAX_HEADER_LEN default 4096: largest HTTP header value string length
libwebsockets can cope with
- LWS_INITIAL_HDR_ALLOC default 256: amount of memory to allocate initially,
tradeoff between taking too much and needless realloc
- LWS_ADDITIONAL_HDR_ALLOC default 64: how much to additionally realloc if
the header value string keeps coming
- MAX_USER_RX_BUFFER default 4096: max amount of user rx data to buffer at a
time and pass to user callback
- MAX_BROADCAST_PAYLOAD default 4096: largest amount of user tx data we can
broadcast at a time
- LWS_MAX_PROTOCOLS default 10: largest amount of different protocols the
server can serve
- LWS_MAX_EXTENSIONS_ACTIVE default 10: largest amount of extensions we can
choose to have active on one connection
- SPEC_LATEST_SUPPORTED default 13: only change if you want to remove support
for later protocol versions... unlikely
- AWAITING_TIMEOUT default 5: after this many seconds without a response, the
server will hang up on the client
- CIPHERS_LIST_STRING default "DEFAULT": SSL Cipher selection
- SYSTEM_RANDOM_FILEPATH default "/dev/urandom": if your random device differs
you can set it here
- LWS_MAX_ZLIB_CONN_BUFFER maximum size a compression buffer is allowed to
grow to before closing the connection. Default is 64KBytes.

View file

@ -9,10 +9,6 @@
#define MIN_SIZE_TO_DEFLATE 4
#ifndef LWS_MAX_ZLIB_CONN_BUFFER
#define LWS_MAX_ZLIB_CONN_BUFFER (64 * 1024)
#endif
int lws_extension_callback_deflate_frame(
struct libwebsocket_context *context,
struct libwebsocket_extension *ext,

View file

@ -2600,6 +2600,21 @@ libwebsocket_create_context(int port, const char *interf,
#endif
lwsl_info("Initial logging level %d\n", log_level);
lwsl_info(" FD_HASHTABLE_MODULUS: %u\n", FD_HASHTABLE_MODULUS);
lwsl_info(" MAX_CLIENTS: %u\n", MAX_CLIENTS);
lwsl_info(" LWS_MAX_HEADER_NAME_LENGTH: %u\n", LWS_MAX_HEADER_NAME_LENGTH);
lwsl_info(" LWS_MAX_HEADER_LEN: %u\n", LWS_MAX_HEADER_LEN);
lwsl_info(" LWS_INITIAL_HDR_ALLOC: %u\n", LWS_INITIAL_HDR_ALLOC);
lwsl_info(" LWS_ADDITIONAL_HDR_ALLOC: %u\n", LWS_ADDITIONAL_HDR_ALLOC);
lwsl_info(" MAX_USER_RX_BUFFER: %u\n", MAX_USER_RX_BUFFER);
lwsl_info(" MAX_BROADCAST_PAYLOAD: %u\n", MAX_BROADCAST_PAYLOAD);
lwsl_info(" LWS_MAX_PROTOCOLS: %u\n", LWS_MAX_PROTOCOLS);
lwsl_info(" LWS_MAX_EXTENSIONS_ACTIVE: %u\n", LWS_MAX_EXTENSIONS_ACTIVE);
lwsl_info(" SPEC_LATEST_SUPPORTED: %u\n", SPEC_LATEST_SUPPORTED);
lwsl_info(" AWAITING_TIMEOUT: %u\n", AWAITING_TIMEOUT);
lwsl_info(" CIPHERS_LIST_STRING: '%s'\n", CIPHERS_LIST_STRING);
lwsl_info(" SYSTEM_RANDOM_FILEPATH: '%s'\n", SYSTEM_RANDOM_FILEPATH);
lwsl_info(" LWS_MAX_ZLIB_CONN_BUFFER: %u\n", LWS_MAX_ZLIB_CONN_BUFFER);
#ifdef _WIN32
{

View file

@ -116,22 +116,55 @@ extern void _lws_log(int filter, const char *format, ...);
#endif
#ifndef FD_HASHTABLE_MODULUS
#define FD_HASHTABLE_MODULUS 32
#endif
#ifndef MAX_CLIENTS
#define MAX_CLIENTS 100
#endif
#ifndef LWS_MAX_HEADER_NAME_LENGTH
#define LWS_MAX_HEADER_NAME_LENGTH 64
#endif
#ifndef LWS_MAX_HEADER_LEN
#define LWS_MAX_HEADER_LEN 4096
#endif
#ifndef LWS_INITIAL_HDR_ALLOC
#define LWS_INITIAL_HDR_ALLOC 256
#endif
#ifndef LWS_ADDITIONAL_HDR_ALLOC
#define LWS_ADDITIONAL_HDR_ALLOC 64
#endif
#ifndef MAX_USER_RX_BUFFER
#define MAX_USER_RX_BUFFER 4096
#endif
#ifndef MAX_BROADCAST_PAYLOAD
#define MAX_BROADCAST_PAYLOAD 4096
#endif
#ifndef LWS_MAX_PROTOCOLS
#define LWS_MAX_PROTOCOLS 10
#endif
#ifndef LWS_MAX_EXTENSIONS_ACTIVE
#define LWS_MAX_EXTENSIONS_ACTIVE 10
#endif
#ifndef SPEC_LATEST_SUPPORTED
#define SPEC_LATEST_SUPPORTED 13
#endif
#ifndef AWAITING_TIMEOUT
#define AWAITING_TIMEOUT 5
#endif
#ifndef CIPHERS_LIST_STRING
#define CIPHERS_LIST_STRING "DEFAULT"
#endif
#define MAX_WEBSOCKET_04_KEY_LEN 128
#ifndef SYSTEM_RANDOM_FILEPATH
#define SYSTEM_RANDOM_FILEPATH "/dev/urandom"
#endif
#ifndef LWS_MAX_ZLIB_CONN_BUFFER
#define LWS_MAX_ZLIB_CONN_BUFFER (64 * 1024)
#endif
enum lws_websocket_opcodes_04 {
LWS_WS_OPCODE_04__CONTINUATION = 0,