[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9157 - in libmicrohttpd: . src/daemon
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9157 - in libmicrohttpd: . src/daemon |
Date: |
Wed, 14 Oct 2009 06:39:50 -0600 |
Author: grothoff
Date: 2009-10-14 06:39:50 -0600 (Wed, 14 Oct 2009)
New Revision: 9157
Modified:
libmicrohttpd/ChangeLog
libmicrohttpd/src/daemon/daemon.c
Log:
Trying to fix the issue reported on the mailinglist at
http://lists.gnu.org/archive/html/libmicrohttpd/2009-10/msg00013.html
Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog 2009-10-14 12:26:42 UTC (rev 9156)
+++ libmicrohttpd/ChangeLog 2009-10-14 12:39:50 UTC (rev 9157)
@@ -1,3 +1,10 @@
+Wed Oct 14 14:37:37 CEST 2009
+ Fixing (rare) deadlock due to SELECT missing SIGALRM by
+ making all SELECT calls block for at most 1s. While this
+ can in (rare) situations delay the shutdown by 1s, I think
+ this is prefereable (both performance and possibly portability-wise)
+ over using a pipe for the signal. -CG
+
Sun Oct 11 14:57:29 CEST 2009
Adding eCos license as an additional license for the
non-HTTPS code of MHD. -CG
Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c 2009-10-14 12:26:42 UTC (rev 9156)
+++ libmicrohttpd/src/daemon/daemon.c 2009-10-14 12:39:50 UTC (rev 9157)
@@ -477,18 +477,22 @@
now = time (NULL);
tv.tv_usec = 0;
if (timeout > (now - con->last_activity))
- tv.tv_sec = timeout - (now - con->last_activity);
+ {
+ /* in case we are missing the SIGALRM, keep going after
+ at most 1s; see
http://lists.gnu.org/archive/html/libmicrohttpd/2009-10/msg00013.html */
+ tv.tv_sec = 1;
+ if ((con->state == MHD_CONNECTION_NORMAL_BODY_UNREADY) ||
+ (con->state == MHD_CONNECTION_CHUNKED_BODY_UNREADY))
+ {
+ /* do not block (we're waiting for our callback to succeed) */
+ tv.tv_sec = 0;
+ }
+ }
else
- tv.tv_sec = 0;
- if ((con->state == MHD_CONNECTION_NORMAL_BODY_UNREADY) ||
- (con->state == MHD_CONNECTION_CHUNKED_BODY_UNREADY))
- {
- /* do not block (we're waiting for our callback to succeed) */
- timeout = 1;
- tv.tv_sec = 0;
- }
- num_ready = SELECT (max + 1,
- &rs, &ws, &es, (timeout != 0) ? &tv : NULL);
+ {
+ tv.tv_sec = 0;
+ }
+ num_ready = SELECT (max + 1, &rs, &ws, &es, &tv);
if (num_ready < 0)
{
if (errno == EINTR)
@@ -901,7 +905,11 @@
return MHD_NO;
FD_SET (max, &rs);
}
-
+
+ /* in case we are missing the SIGALRM, keep going after
+ at most 1s; see
http://lists.gnu.org/archive/html/libmicrohttpd/2009-10/msg00013.html */
+ timeout.tv_usec = 0;
+ timeout.tv_sec = 1;
if (may_block == MHD_NO)
{
timeout.tv_usec = 0;
@@ -910,17 +918,15 @@
else
{
/* ltimeout is in ms */
- if (MHD_YES == MHD_get_timeout (daemon, <imeout))
- {
- timeout.tv_usec = (ltimeout % 1000) * 1000;
- timeout.tv_sec = ltimeout / 1000;
- may_block = MHD_NO;
+ if ( (MHD_YES == MHD_get_timeout (daemon, <imeout)) &&
+ (ltimeout < 1000) )
+ {
+ timeout.tv_usec = ltimeout * 1000;
+ timeout.tv_sec = 0;
}
}
+ num_ready = SELECT (max + 1, &rs, &ws, &es, &timeout);
- num_ready = select (max + 1, &rs, &ws, &es, may_block == MHD_NO ? &timeout
- : NULL);
-
if (daemon->shutdown == MHD_YES)
return MHD_NO;
if (num_ready < 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9157 - in libmicrohttpd: . src/daemon,
gnunet <=