Fixed dual stack

This commit is contained in:
Thomas Kolb 2013-08-21 15:29:03 +02:00
parent 57d0d90d64
commit 7a3d20ee25

View file

@ -609,10 +609,7 @@ int parse_cmdline(int argc, char **argv, int *port, int *enableUpload, char **sh
int main(int argc, char ** argv) { int main(int argc, char ** argv) {
struct MHD_Daemon *d; struct MHD_Daemon *d;
#if MHD_VERSION <= 0x00092100
struct MHD_Daemon *d6; struct MHD_Daemon *d6;
#endif
struct stat sBuf; struct stat sBuf;
@ -708,7 +705,6 @@ int main(int argc, char ** argv) {
faviconResponse = create_favicon_response(); faviconResponse = create_favicon_response();
// start daemons // start daemons
#if MHD_VERSION <= 0x00092100
d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION,
port, port,
NULL, NULL,
@ -724,7 +720,16 @@ int main(int argc, char ** argv) {
LOG(LVL_DEBUG, "IPv4 daemon startup successful."); LOG(LVL_DEBUG, "IPv4 daemon startup successful.");
} }
d6 = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_IPv6, #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
d6 = MHD_start_daemon(flags,
port, port,
NULL, NULL,
NULL, NULL,
@ -743,24 +748,6 @@ int main(int argc, char ** argv) {
LOG(LVL_FATAL, "Both IPv4 and IPv6 servers failed to start. Terminating."); LOG(LVL_FATAL, "Both IPv4 and IPv6 servers failed to start. Terminating.");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#else
d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DUAL_STACK,
port,
NULL,
NULL,
&connection_handler,
NULL,
MHD_OPTION_NOTIFY_COMPLETED,
&request_completed, NULL,
MHD_OPTION_END);
if (d == NULL) {
LOG(LVL_FATAL, "Cannot start up libmicrohttpd listening on dual stack socket.");
return EXIT_FAILURE;
} else {
LOG(LVL_DEBUG, "Dual stack daemon startup successful.");
}
#endif // MHD_VERSION
LOG(LVL_INFO, "Startup successful. Here are the IP addresses for this computer:"); LOG(LVL_INFO, "Startup successful. Here are the IP addresses for this computer:");
print_urls(port); print_urls(port);
@ -772,10 +759,7 @@ int main(int argc, char ** argv) {
LOG(LVL_INFO, "Shutting down..."); LOG(LVL_INFO, "Shutting down...");
MHD_stop_daemon(d); MHD_stop_daemon(d);
#if MHD_VERSION <= 0x00092100
MHD_stop_daemon(d6); MHD_stop_daemon(d6);
#endif
MHD_destroy_response(error403Response); MHD_destroy_response(error403Response);
MHD_destroy_response(error404Response); MHD_destroy_response(error404Response);