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