libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 41c097c15e2d49006847779773aeb9823a6d44d7
parent 8a731a26ae3c5ed5387b933f039569a6f4a8e3e4
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 20 Sep 2020 16:28:07 +0300

Re-factor debugging macros.
'MHD_NO' is meaningless for precompiler, used special macro instead

Diffstat:
Msrc/microhttpd/connection.c | 14++------------
Msrc/microhttpd/daemon.c | 22+++++-----------------
Msrc/microhttpd/internal.h | 40+++++++++++++++++++++++++++++++++++++---
3 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -114,16 +114,6 @@ #define INTERNAL_ERROR "" #endif -/** - * Add extra debug messages with reasons for closing connections - * (non-error reasons). - */ -#define DEBUG_CLOSE MHD_NO - -/** - * Should all data send be printed to stderr? - */ -#define DEBUG_SEND_DATA MHD_NO /** @@ -2933,7 +2923,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) NULL); return; } -#if DEBUG_SEND_DATA +#if _MHD_DEBUG_SEND_DATA fprintf (stderr, _ ("Sent 100 continue response: `%.*s'\n"), (int) ret, @@ -3037,7 +3027,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) response->data_size - (size_t) data_write_offset, MHD_SSO_NO_CORK); -#if DEBUG_SEND_DATA +#if _MHD_DEBUG_SEND_DATA if (ret > 0) fprintf (stderr, _ ("Sent %d-byte DATA response: `%.*s'\n"), diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -77,18 +77,6 @@ */ #define MHD_POOL_SIZE_DEFAULT (32 * 1024) -/** - * Print extra messages with reasons for closing - * sockets? (only adds non-error messages). - */ -#define DEBUG_CLOSE MHD_NO - -/** - * Print extra messages when establishing - * connections? (only adds non-error messages). - */ -#define DEBUG_CONNECT MHD_NO - /* Forward declarations. */ @@ -1081,7 +1069,7 @@ internal_get_fdset2 (struct MHD_Daemon *daemon, } } #endif -#if DEBUG_CONNECT +#if _MHD_DEBUG_CONNECT #ifdef HAVE_MESSAGES if (NULL != max_fd) MHD_DLOG (daemon, @@ -2178,7 +2166,7 @@ thread_main_handle_connection (void *data) } #endif /* UPGRADE_SUPPORT */ } -#if DEBUG_CLOSE +#if _MHD_DEBUG_CLOSE #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Processing thread terminating. Closing connection.\n")); @@ -2449,7 +2437,7 @@ internal_add_connection (struct MHD_Daemon *daemon, #ifdef HAVE_MESSAGES -#if DEBUG_CONNECT +#if _MHD_DEBUG_CONNECT MHD_DLOG (daemon, _ ("Accepted connection on socket %d.\n"), client_socket); @@ -2479,7 +2467,7 @@ internal_add_connection (struct MHD_Daemon *daemon, addr, addrlen)) ) { -#if DEBUG_CLOSE +#if _MHD_DEBUG_CLOSE #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Connection rejected by application. Closing connection.\n")); @@ -3310,7 +3298,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) } #endif /* !USE_ACCEPT4 || !SOCK_CLOEXEC */ #ifdef HAVE_MESSAGES -#if DEBUG_CONNECT +#if _MHD_DEBUG_CONNECT MHD_DLOG (daemon, _ ("Accepted connection on socket %d\n"), s); diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -76,6 +76,18 @@ /** + * @def _MHD_MACRO_NO + * "Negative answer"/"false" for use in macros, meaningful for precompiler + */ +#define _MHD_MACRO_NO 0 + +/** + * @def _MHD_MACRO_YES + * "Positive answer"/"true" for use in macros, meaningful for precompiler + */ +#define _MHD_MACRO_YES 1 + +/** * Close FD and abort execution if error is detected. * @param fd the FD to close */ @@ -84,11 +96,33 @@ MHD_PANIC (_ ("Failed to close FD.\n")); \ } while (0) +/* +#define EXTRA_CHECKS _MHD_MACRO_NO + * Not used. Behaviour is controlled by _DEBUG/NDEBUG macros. + */ + +#ifndef _MHD_DEBUG_CONNECT +/** + * Print extra messages when establishing + * connections? (only adds non-error messages). + */ +#define _MHD_DEBUG_CONNECT _MHD_MACRO_NO +#endif /* ! _MHD_DEBUG_CONNECT */ + +#ifndef _MHD_DEBUG_SEND_DATA +/** + * Should all data send be printed to stderr? + */ +#define _MHD_DEBUG_SEND_DATA _MHD_MACRO_NO +#endif /* ! _MHD_DEBUG_SEND_DATA */ + +#ifndef _MHD_DEBUG_CLOSE /** - * Should we perform additional sanity checks at runtime (on our internal - * invariants)? This may lead to aborts, but can be useful for debugging. + * Add extra debug messages with reasons for closing connections + * (non-error reasons). */ -#define EXTRA_CHECKS MHD_NO +#define _MHD_DEBUG_CLOSE _MHD_MACRO_NO +#endif /* ! _MHD_DEBUG_CLOSE */ #define MHD_MAX(a,b) (((a)<(b)) ? (b) : (a)) #define MHD_MIN(a,b) (((a)<(b)) ? (a) : (b))