[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 02/02: Re-factor debugging macros. 'MHD_NO' is meaningle
From: |
gnunet |
Subject: |
[libmicrohttpd] 02/02: Re-factor debugging macros. 'MHD_NO' is meaningless for precompiler, used special macro instead |
Date: |
Sun, 20 Sep 2020 15:35:06 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 41c097c15e2d49006847779773aeb9823a6d44d7
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Sep 20 16:28:07 2020 +0300
Re-factor debugging macros.
'MHD_NO' is meaningless for precompiler, used special macro instead
---
src/microhttpd/connection.c | 14 ++------------
src/microhttpd/daemon.c | 22 +++++-----------------
src/microhttpd/internal.h | 40 +++++++++++++++++++++++++++++++++++++---
3 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index f9f15cec..cf2bfaa1 100644
--- 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
index 775faa0b..a9151fc5 100644
--- 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
index 8f0e821a..cfaca9af 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -75,6 +75,18 @@
#include "mhd_itc_types.h"
+/**
+ * @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))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.