From c198d2e5f145799fcd0d3027de62f01c29777c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=B1=D0=B1=D0=B8?= Date: Fri, 7 Dec 2018 09:18:29 +0000 Subject: [PATCH] Make MG_CTL_MSG_MESSAGE_SIZE overridable CL: Make MG_CTL_MSG_MESSAGE_SIZE overridable Fix https://github.com/cesanta/mongoose/pull/987 PUBLISHED_FROM=b0a7c67297b98f616c9eadcd3c34b8747939c918 --- docs/c-api/mg_net.h/mg_broadcast.md | 2 +- mongoose.c | 2 ++ mongoose.h | 2 +- src/mg_internal.h | 2 ++ src/mg_net.h | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/c-api/mg_net.h/mg_broadcast.md b/docs/c-api/mg_net.h/mg_broadcast.md index cef0b379..6e966afe 100644 --- a/docs/c-api/mg_net.h/mg_broadcast.md +++ b/docs/c-api/mg_net.h/mg_broadcast.md @@ -16,5 +16,5 @@ that can be, and must be, called from a different (non-IO) thread. `func` callback function will be called by the IO thread for each connection. When called, the event will be `MG_EV_POLL`, and a message will be passed as the `ev_data` pointer. Maximum message size is capped -by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes. +by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes by default. diff --git a/mongoose.c b/mongoose.c index ffa97c9b..3196c065 100644 --- a/mongoose.c +++ b/mongoose.c @@ -38,7 +38,9 @@ /* Amalgamated: #include "mg_http.h" */ /* Amalgamated: #include "mg_net.h" */ +#ifndef MG_CTL_MSG_MESSAGE_SIZE #define MG_CTL_MSG_MESSAGE_SIZE 8192 +#endif /* internals that need to be accessible in unit tests */ MG_INTERNAL struct mg_connection *mg_do_connect(struct mg_connection *nc, diff --git a/mongoose.h b/mongoose.h index 8d9e8f29..2b7c0830 100644 --- a/mongoose.h +++ b/mongoose.h @@ -4034,7 +4034,7 @@ int mg_mgr_poll(struct mg_mgr *mgr, int milli); * `func` callback function will be called by the IO thread for each * connection. When called, the event will be `MG_EV_POLL`, and a message will * be passed as the `ev_data` pointer. Maximum message size is capped - * by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes. + * by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes by default. */ void mg_broadcast(struct mg_mgr *mgr, mg_event_handler_t cb, void *data, size_t len); diff --git a/src/mg_internal.h b/src/mg_internal.h index 20614234..0e62448e 100644 --- a/src/mg_internal.h +++ b/src/mg_internal.h @@ -34,7 +34,9 @@ #include "mg_http.h" #include "mg_net.h" +#ifndef MG_CTL_MSG_MESSAGE_SIZE #define MG_CTL_MSG_MESSAGE_SIZE 8192 +#endif /* internals that need to be accessible in unit tests */ MG_INTERNAL struct mg_connection *mg_do_connect(struct mg_connection *nc, diff --git a/src/mg_net.h b/src/mg_net.h index d854e770..aa8ed171 100644 --- a/src/mg_net.h +++ b/src/mg_net.h @@ -225,7 +225,7 @@ int mg_mgr_poll(struct mg_mgr *mgr, int milli); * `func` callback function will be called by the IO thread for each * connection. When called, the event will be `MG_EV_POLL`, and a message will * be passed as the `ev_data` pointer. Maximum message size is capped - * by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes. + * by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes by default. */ void mg_broadcast(struct mg_mgr *mgr, mg_event_handler_t cb, void *data, size_t len);