libmicrohttpd

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

commit d8a567a4698247a376323cb5c74c3966db90c488
parent 2118763c481d6a23af5eb3f652f4689086cdbf4c
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 12 Jul 2014 18:57:56 +0000

code cleanup, expand assertions

Diffstat:
Msrc/microhttpd/connection.c | 2+-
Msrc/microhttpd/internal.h | 20++++++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2003,7 +2003,7 @@ update_last_activity (struct MHD_Connection *connection) connection->last_activity = MHD_monotonic_time(); if (connection->connection_timeout != daemon->connection_timeout) - return; /* custom timeout, no need to move it in DLL */ + return; /* custom timeout, no need to move it in "normal" DLL */ /* move connection to head of timeout list (by remove + add operation) */ if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -541,6 +541,10 @@ struct MHD_Connection /** * Next pointer for the XDLL organizing connections by timeout. + * This DLL can be either the + * 'manual_timeout_head/manual_timeout_tail' or the + * 'normal_timeout_head/normal_timeout_tail', depending on whether a + * custom timeout is set for the connection. */ struct MHD_Connection *nextX; @@ -1258,7 +1262,7 @@ struct MHD_Daemon #if EXTRA_CHECKS -#define EXTRA_CHECK(a) if (!(a)) abort(); +#define EXTRA_CHECK(a) do { if (!(a)) abort(); } while (0) #else #define EXTRA_CHECK(a) #endif @@ -1273,6 +1277,8 @@ struct MHD_Daemon * @param element element to insert */ #define DLL_insert(head,tail,element) do { \ + EXTRA_CHECK (NULL == (element)->next); \ + EXTRA_CHECK (NULL == (element)->prev); \ (element)->next = (head); \ (element)->prev = NULL; \ if ((tail) == NULL) \ @@ -1292,6 +1298,8 @@ struct MHD_Daemon * @param element element to remove */ #define DLL_remove(head,tail,element) do { \ + EXTRA_CHECK ( (NULL != (element)->next) || ((element) == (tail))); \ + EXTRA_CHECK ( (NULL != (element)->prev) || ((element) == (head))); \ if ((element)->prev == NULL) \ (head) = (element)->next; \ else \ @@ -1314,9 +1322,11 @@ struct MHD_Daemon * @param element element to insert */ #define XDLL_insert(head,tail,element) do { \ + EXTRA_CHECK (NULL == (element)->nextX); \ + EXTRA_CHECK (NULL == (element)->prevX); \ (element)->nextX = (head); \ (element)->prevX = NULL; \ - if ((tail) == NULL) \ + if (NULL == (tail)) \ (tail) = element; \ else \ (head)->prevX = element; \ @@ -1333,11 +1343,13 @@ struct MHD_Daemon * @param element element to remove */ #define XDLL_remove(head,tail,element) do { \ - if ((element)->prevX == NULL) \ + EXTRA_CHECK ( (NULL != (element)->nextX) || ((element) == (tail))); \ + EXTRA_CHECK ( (NULL != (element)->prevX) || ((element) == (head))); \ + if (NULL == (element)->prevX) \ (head) = (element)->nextX; \ else \ (element)->prevX->nextX = (element)->nextX; \ - if ((element)->nextX == NULL) \ + if (NULL == (element)->nextX) \ (tail) = (element)->prevX; \ else \ (element)->nextX->prevX = (element)->prevX; \