diff options
author | Aaron Merey <amerey@redhat.com> | 2022-09-02 21:23:32 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 2022-09-05 13:17:32 -0400 |
commit | a176b6e30aa8983c95b81f18c34a2b5c6a0c907b (patch) | |
tree | 5fc7f5863b93414534a3f7cb44530ff5dbdec203 /debuginfod | |
parent | 8c68c312699e196d8f9ad14d378762cfd8bc2c94 (diff) | |
download | elfutils-a176b6e30aa8983c95b81f18c34a2b5c6a0c907b.tar.gz |
debuginfod: Use auto-sized connection pool when -C is not given with arg
Since commit 4b42d9ad, libmicrohttpd's epoll event loop is used when
available in which case we must disable its setting for spawning a thread
per request. This contradicts the debuginfod doc's description of '-C',
which indicates that if this command line option is not given then the
thread pool size is unbounded.
Fix this by using an auto-sized thread pool when '-C' is not given, just
as we do when it's given with no argument. Update the doc's description
of '-C'.
Also use a fixed-size pool even if epoll is not supported. The unbounded
pool config cannot be considered entirely reliable as it appears to cause
random fails in the run-debuginfod-webapi-concurrency test.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Diffstat (limited to 'debuginfod')
-rw-r--r-- | debuginfod/ChangeLog | 7 | ||||
-rw-r--r-- | debuginfod/debuginfod.cxx | 22 |
2 files changed, 17 insertions, 12 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index da58e9a8..c692a389 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,10 @@ +2022-09-02 Aaron Merey <amerey@redhat.com> + + * debuginfod.cxx (parse_opt): If '-C' is given with no arg, do not + update connection_pool since it will be done at a later point. + (main): Use auto-sized connection_pool if '-C' isn't given with an + arg. Do not use MHD_USE_THREAD_PER_CONNECTION. + 2022-08-17 Martin Liska <mliska@suse.cz> * debuginfod.cxx (handle_buildid): Update HTTP statistics only if diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 3e2dd9ef..8680c048 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -575,8 +575,6 @@ parse_opt (int key, char *arg, if (connection_pool < 2) argp_failure(state, 1, EINVAL, "-C NUM minimum 2"); } - else // arg not given - connection_pool = std::thread::hardware_concurrency() * 2 ?: 2; break; case 'I': // NB: no problem with unconditional free here - an earlier failed regcomp would exit program @@ -3937,6 +3935,11 @@ main (int argc, char *argv[]) } } + /* If '-C' wasn't given or was given with no arg, pick a reasonable default + for the number of worker threads. */ + if (connection_pool == 0) + connection_pool = std::thread::hardware_concurrency() * 2 ?: 2; + /* Note that MHD_USE_EPOLL and MHD_USE_THREAD_PER_CONNECTION don't work together. */ unsigned int use_epoll = 0; @@ -3944,12 +3947,11 @@ main (int argc, char *argv[]) use_epoll = MHD_USE_EPOLL; #endif - unsigned int mhd_flags = ((connection_pool || use_epoll - ? 0 : MHD_USE_THREAD_PER_CONNECTION) + unsigned int mhd_flags = ( #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 | use_epoll @@ -3964,12 +3966,8 @@ main (int argc, char *argv[]) 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_THREAD_POOL_SIZE, + (int)connection_pool, MHD_OPTION_END); MHD_Daemon *d4 = NULL; |