[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35510 - in libmicrohttpd: . src/microhttpd
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35510 - in libmicrohttpd: . src/microhttpd |
Date: |
Thu, 9 Apr 2015 09:03:26 +0200 |
Author: grothoff
Date: 2015-04-09 09:03:26 +0200 (Thu, 09 Apr 2015)
New Revision: 35510
Modified:
libmicrohttpd/AUTHORS
libmicrohttpd/ChangeLog
libmicrohttpd/src/microhttpd/daemon.c
Log:
Hi all,
I was trying to use MHD_suspend_connection() and MHD_resume_connection() to
implement long polling on a request. I am using options
MHD_USE_SELECT_INTERNALLY and MHD_USE_POLL options. I noticed the server thread
went to 100% CPU after the first MHD_resume_connection() call. Looking at the
code in MHD_poll_all() I can see that the file descriptor from daemon->wpipe[0]
gets inserted into the list of file descriptors to poll but this file
descriptor is never read so every time this function is called it returns
immediately. The code works fine if I drop to using just
MHD_USE_SELECT_INTERNALLY.
The patch below fixes the problem.
Regards,
Denis
Modified: libmicrohttpd/AUTHORS
===================================================================
--- libmicrohttpd/AUTHORS 2015-04-07 23:57:13 UTC (rev 35509)
+++ libmicrohttpd/AUTHORS 2015-04-09 07:03:26 UTC (rev 35510)
@@ -52,6 +52,7 @@
Hani Benhabiles <address@hidden>
Guy Martin <address@hidden>
Robert Groenenberg <address@hidden>
+Denis Dowling <address@hidden>
Documentation contributions also came from:
Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog 2015-04-07 23:57:13 UTC (rev 35509)
+++ libmicrohttpd/ChangeLog 2015-04-09 07:03:26 UTC (rev 35510)
@@ -1,3 +1,8 @@
+Thu Apr 9 09:01:15 CEST 2015
+ Fixing issue with undrained signal pipe when using
+ MHD_USE_SELECT_INTERNALLY and MHD_USE_POLL in combination
+ with MHD_resume_connection(), causing 100% CPU usage. -DD
+
Tue Apr 7 00:12:36 CEST 2015
Releasing libmicrohttpd 0.9.40. -CG
Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c 2015-04-07 23:57:13 UTC (rev
35509)
+++ libmicrohttpd/src/microhttpd/daemon.c 2015-04-09 07:03:26 UTC (rev
35510)
@@ -2317,6 +2317,8 @@
int timeout;
unsigned int poll_server;
int poll_listen;
+ int poll_pipe;
+ char tmp;
memset (p, 0, sizeof (p));
poll_server = 0;
@@ -2331,11 +2333,13 @@
poll_listen = (int) poll_server;
poll_server++;
}
+ poll_pipe = -1;
if (MHD_INVALID_PIPE_ != daemon->wpipe[0])
{
p[poll_server].fd = daemon->wpipe[0];
p[poll_server].events = POLLIN;
p[poll_server].revents = 0;
+ poll_pipe = (int) poll_server;
poll_server++;
}
if (may_block == MHD_NO)
@@ -2433,6 +2437,11 @@
if ( (-1 != poll_listen) &&
(0 != (p[poll_listen].revents & POLLIN)) )
(void) MHD_accept_connection (daemon);
+
+ /* handle pipe FD */
+ if ( (-1 != poll_pipe) &&
+ (0 != (p[poll_pipe].revents & POLLIN)) )
+ (void) MHD_pipe_read_ (daemon->wpipe[0], &tmp, sizeof (tmp));
}
return MHD_YES;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35510 - in libmicrohttpd: . src/microhttpd,
gnunet <=