summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2022-05-05 23:59:57 +0200
committerMark Wielaard <mark@klomp.org>2022-05-12 00:54:04 +0200
commit51571ca7685fad821eb98eaa481f64de7f44bb07 (patch)
tree5da82bdf7ba6e1cb6e957d5473a2df7f28045a60
parentc7982c9e3bee93422dd140568587e2796e0c96ca (diff)
downloadelfutils-51571ca7685fad821eb98eaa481f64de7f44bb07.tar.gz
debuginfod: Try without MHD_USE_DUAL_STACK if MHD_start_daemon fails
On a systems that have ipv6 disabled debuginfod doesn't start up anymore because libhttpd MHD_USE_DUAL_STACK only works if it can open an ipv6 socket. If MHD_start_daemon with MHD_USE_DUAL_STACK fails try again without that flag set. https://sourceware.org/bugzilla/show_bug.cgi?id=29122 Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r--debuginfod/ChangeLog7
-rw-r--r--debuginfod/debuginfod.cxx74
2 files changed, 58 insertions, 23 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 026908c8..29480c9c 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,10 @@
+2022-05-05 Mark Wielaard <mark@klomp.org>
+
+ * debuginfod.cxx (main): Define mhd_flags. Use mhd_flags for
+ MHD_start_daemon. Try again with MHD_USE_DUAL_STACK removed if
+ that fails. Update clog to say either IPV4 or IPV4 and IPV6.
+ stop either ithe d46 or d4 daemonr.
+
2022-05-09 Noah Sanci <nsanci@redhat.com>
* debuginfod.cxx (main): Set nonzero defaults for fdcache.
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index fde4e194..8692a424 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -3906,40 +3906,67 @@ main (int argc, char *argv[])
}
}
- // Start httpd server threads. Use a single dual-homed pool.
- MHD_Daemon *d46 = MHD_start_daemon ((connection_pool ? 0 : MHD_USE_THREAD_PER_CONNECTION)
+ unsigned int mhd_flags = ((connection_pool
+ ? 0 : MHD_USE_THREAD_PER_CONNECTION)
#if MHD_VERSION >= 0x00095300
- | MHD_USE_INTERNAL_POLLING_THREAD
+ | MHD_USE_INTERNAL_POLLING_THREAD
#else
- | MHD_USE_SELECT_INTERNALLY
+ | MHD_USE_SELECT_INTERNALLY
#endif
+ | MHD_USE_DUAL_STACK
#ifdef MHD_USE_EPOLL
- | MHD_USE_EPOLL
+ | MHD_USE_EPOLL
#endif
- | MHD_USE_DUAL_STACK
#if MHD_VERSION >= 0x00095200
- | MHD_USE_ITC
+ | MHD_USE_ITC
#endif
- | MHD_USE_DEBUG, /* report errors to stderr */
- http_port,
- NULL, NULL, /* default accept policy */
- handler_cb, NULL, /* handler callback */
- MHD_OPTION_EXTERNAL_LOGGER, error_cb, NULL,
- (connection_pool ? MHD_OPTION_THREAD_POOL_SIZE : MHD_OPTION_END),
- (connection_pool ? (int)connection_pool : MHD_OPTION_END),
- MHD_OPTION_END);
+ | MHD_USE_DEBUG); /* report errors to stderr */
+ // Start httpd server threads. Use a single dual-homed pool.
+ MHD_Daemon *d46 = MHD_start_daemon (mhd_flags, http_port,
+ NULL, NULL, /* default accept policy */
+ handler_cb, NULL, /* handler callback */
+ MHD_OPTION_EXTERNAL_LOGGER,
+ error_cb, NULL,
+ (connection_pool
+ ? MHD_OPTION_THREAD_POOL_SIZE
+ : MHD_OPTION_END),
+ (connection_pool
+ ? (int)connection_pool
+ : MHD_OPTION_END),
+ MHD_OPTION_END);
+
+ MHD_Daemon *d4 = NULL;
if (d46 == NULL)
{
- sqlite3 *database = db;
- sqlite3 *databaseq = dbq;
- db = dbq = 0; // for signal_handler not to freak
- sqlite3_close (databaseq);
- sqlite3_close (database);
- error (EXIT_FAILURE, 0, "cannot start http server at port %d", http_port);
- }
+ // Cannot use dual_stack, use ipv4 only
+ mhd_flags &= ~(MHD_USE_DUAL_STACK);
+ d4 = MHD_start_daemon (mhd_flags, http_port,
+ NULL, NULL, /* default accept policy */
+ handler_cb, NULL, /* handler callback */
+ MHD_OPTION_EXTERNAL_LOGGER,
+ error_cb, NULL,
+ (connection_pool
+ ? MHD_OPTION_THREAD_POOL_SIZE
+ : MHD_OPTION_END),
+ (connection_pool
+ ? (int)connection_pool
+ : MHD_OPTION_END),
+ MHD_OPTION_END);
+ if (d4 == NULL)
+ {
+ sqlite3 *database = db;
+ sqlite3 *databaseq = dbq;
+ db = dbq = 0; // for signal_handler not to freak
+ sqlite3_close (databaseq);
+ sqlite3_close (database);
+ error (EXIT_FAILURE, 0, "cannot start http server at port %d",
+ http_port);
+ }
- obatched(clog) << "started http server on IPv4 IPv6 "
+ }
+ obatched(clog) << "started http server on"
+ << (d4 != NULL ? " IPv4 " : " IPv4 IPv6 ")
<< "port=" << http_port << endl;
// add maxigroom sql if -G given
@@ -4060,6 +4087,7 @@ main (int argc, char *argv[])
/* Stop all the web service threads. */
if (d46) MHD_stop_daemon (d46);
+ if (d4) MHD_stop_daemon (d4);
if (! passive_p)
{