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