From b86f93acaf57b6757daa8e8b0934d2a5bc29bf74 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 14 Apr 2015 22:34:15 +0000 Subject: [PATCH] HI, The MHD goes in a busy loop when it is configured with MHD_USE_POLL_INTERNALLY and a connection times out. When the connection times out, the connection is closed at connection.c:2646, which sets connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP. When the loop info is set to MHD_EVENT_LOOP_INFO_CLEANUP, the main function of the thread loop, MHD_poll_all, never calls back the connection idle callback, which would have cleaned the connection and exit the loop. I resolved the issue in my development code by adding pos->idle_handler (pos) at daemon.c:2477 in MHD_poll_all (SVN 35533). The busy loop could be tested using a small enough connection timeout and netcat: nc -v -w 100 CPU usage will reach 100% in one of the CPU and will remain at that level even when the netcat has closed its end of the connection. Thanks, Louis Benoit --- AUTHORS | 1 + ChangeLog | 4 ++++ src/include/microhttpd.h | 2 +- src/microhttpd/daemon.c | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index a441dfa8..8a040965 100644 --- a/AUTHORS +++ b/AUTHORS @@ -53,6 +53,7 @@ Hani Benhabiles Guy Martin Robert Groenenberg Denis Dowling +Louis Benoit Documentation contributions also came from: diff --git a/ChangeLog b/ChangeLog index 710e86eb..67aa2115 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Apr 15 00:30:34 CEST 2015 + Fix looping issue when using MHD_USE_POLL_INTERNALLY + and a client times out. -LB + Sun Apr 12 21:48:50 CEST 2015 Fix looping issue when combining MHD_USE_EPOLL_LINUX_ONLY with HTTPS and slow clients. -CG diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 93c4c212..69fdd1d9 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h @@ -130,7 +130,7 @@ typedef intptr_t ssize_t; * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00094004 +#define MHD_VERSION 0x00094005 /** * MHD-internal return code for "YES". diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 950b551b..876030b0 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -2474,7 +2474,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, pos->idle_handler (pos); break; case MHD_EVENT_LOOP_INFO_CLEANUP: - /* should never happen */ + pos->idle_handler (pos); break; } }