From 3d0e4aa0b646dc8c5806f0f65debc3bbb6e8e203 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 21 Dec 2014 22:06:51 +0100 Subject: [PATCH] Fixed dual stack support for current libmicrohttpd --- src/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index 54bd89b..b9e2e25 100644 --- a/src/main.c +++ b/src/main.c @@ -657,8 +657,8 @@ int parse_cmdline(int argc, char **argv, int *port, int *enableUpload, char **sh } int main(int argc, char ** argv) { - struct MHD_Daemon *d; - struct MHD_Daemon *d6; + struct MHD_Daemon *d = NULL; + struct MHD_Daemon *d6 = NULL; struct stat sBuf; @@ -754,6 +754,7 @@ int main(int argc, char ** argv) { faviconResponse = create_favicon_response(); // start daemons +#if MHD_VERSION <= 0x00092100 d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, port, NULL, @@ -769,12 +770,8 @@ int main(int argc, char ** argv) { LOG(LVL_DEBUG, "IPv4 daemon startup successful."); } -#if MHD_VERSION <= 0x00092100 unsigned int flags = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_IPv6; #else - /* MHD_USE_DUAL_STACK does actually not bind the socket to both IPv4 and - * IPv6, but bind the socket to IPv6 ONLY (just the opposite of what is - * documented. WATCH THIS CLOSELY FOR UPDATES! */ unsigned int flags = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DUAL_STACK; #endif // MHD_VERSION @@ -790,11 +787,11 @@ int main(int argc, char ** argv) { if (d6 == NULL) { LOG(LVL_ERR, "Cannot start up libmicrohttpd listening on IPv6."); } else { - LOG(LVL_DEBUG, "IPv6 daemon startup successful."); + LOG(LVL_DEBUG, "IPv6/Dualstack daemon startup successful."); } if(d == NULL && d6 == NULL) { - LOG(LVL_FATAL, "Both IPv4 and IPv6 servers failed to start. Terminating."); + LOG(LVL_FATAL, "Both IPv4 and IPv6/Dualstack servers failed to start. Terminating."); return EXIT_FAILURE; } @@ -807,7 +804,10 @@ int main(int argc, char ** argv) { LOG(LVL_INFO, "Shutting down..."); +#if MHD_VERSION <= 0x00092100 MHD_stop_daemon(d); +#endif // MHD_VERSION + MHD_stop_daemon(d6); MHD_destroy_response(error403Response);