98570d
commit 28f9d86ea89f88b24f1d12c8e9d5ddc3f77da194
98570d
Author: Mark Wielaard <mark@klomp.org>
98570d
Date:   Fri May 6 00:29:28 2022 +0200
98570d
98570d
    debuginfod: Use MHD_USE_EPOLL for libmicrohttpd version 0.9.51 or higher
98570d
    
98570d
    Also disable MHD_USE_THREAD_PER_CONNECTION when using MHD_USE_EPOLL.
98570d
    
98570d
    https://sourceware.org/bugzilla/show_bug.cgi?id=29123
98570d
    
98570d
    Signed-off-by: Mark Wielaard <mark@klomp.org>
98570d
98570d
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
98570d
index c02540f1..d4f47bf7 100644
98570d
--- a/debuginfod/debuginfod.cxx
98570d
+++ b/debuginfod/debuginfod.cxx
98570d
@@ -1,6 +1,6 @@
98570d
 /* Debuginfo-over-http server.
98570d
    Copyright (C) 2019-2021 Red Hat, Inc.
98570d
-   Copyright (C) 2021 Mark J. Wielaard <mark@klomp.org>
98570d
+   Copyright (C) 2021, 2022 Mark J. Wielaard <mark@klomp.org>
98570d
    This file is part of elfutils.
98570d
 
98570d
    This file is free software; you can redistribute it and/or modify
98570d
@@ -3899,7 +3899,14 @@ main (int argc, char *argv[])
98570d
         }
98570d
     }
98570d
 
98570d
-  unsigned int mhd_flags = ((connection_pool
98570d
+  /* Note that MHD_USE_EPOLL and MHD_USE_THREAD_PER_CONNECTION don't
98570d
+     work together.  */
98570d
+  unsigned int use_epoll = 0;
98570d
+#if MHD_VERSION >= 0x00095100
98570d
+  use_epoll = MHD_USE_EPOLL;
98570d
+#endif
98570d
+
98570d
+  unsigned int mhd_flags = ((connection_pool || use_epoll
98570d
 			     ? 0 : MHD_USE_THREAD_PER_CONNECTION)
98570d
 #if MHD_VERSION >= 0x00095300
98570d
 			    | MHD_USE_INTERNAL_POLLING_THREAD
98570d
@@ -3907,9 +3914,7 @@ main (int argc, char *argv[])
98570d
 			    | MHD_USE_SELECT_INTERNALLY
98570d
 #endif
98570d
 			    | MHD_USE_DUAL_STACK
98570d
-#ifdef MHD_USE_EPOLL
98570d
-			    | MHD_USE_EPOLL
98570d
-#endif
98570d
+			    | use_epoll
98570d
 #if MHD_VERSION >= 0x00095200
98570d
 			    | MHD_USE_ITC
98570d
 #endif