Fixed dual stack support for current libmicrohttpd

This commit is contained in:
Thomas Kolb 2014-12-21 22:06:51 +01:00
parent ec3640f15b
commit 3d0e4aa0b6
1 changed files with 8 additions and 8 deletions

View File

@ -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);