[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5567 - libmicrohttpd/src/daemon
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5567 - libmicrohttpd/src/daemon |
Date: |
Wed, 29 Aug 2007 19:20:29 -0600 (MDT) |
Author: grothoff
Date: 2007-08-29 19:20:29 -0600 (Wed, 29 Aug 2007)
New Revision: 5567
Modified:
libmicrohttpd/src/daemon/daemon.c
Log:
do not accept forever
Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c 2007-08-30 01:18:15 UTC (rev 5566)
+++ libmicrohttpd/src/daemon/daemon.c 2007-08-30 01:20:29 UTC (rev 5567)
@@ -447,7 +447,6 @@
unsigned long long ltimeout;
int ds;
time_t now;
- int go_again;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
@@ -455,89 +454,81 @@
abort ();
if (daemon->shutdown == MHD_YES)
return MHD_NO;
- go_again = MHD_YES;
- while (go_again == MHD_YES)
+ FD_ZERO (&rs);
+ FD_ZERO (&ws);
+ FD_ZERO (&es);
+ max = 0;
+
+ if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
- go_again = MHD_NO;
- FD_ZERO (&rs);
- FD_ZERO (&ws);
- FD_ZERO (&es);
- max = 0;
-
- if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
- {
- /* single-threaded, go over everything */
- if (MHD_NO == MHD_get_fdset (daemon, &rs, &ws, &es, &max))
- return MHD_NO;
- }
- else
- {
- /* accept only, have one thread per connection */
- max = daemon->socket_fd;
- if (max == -1)
- return MHD_NO;
- FD_SET (max, &rs);
- }
- if (may_block == MHD_NO)
- {
- timeout.tv_usec = 0;
- timeout.tv_sec = 0;
- }
- 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;
- }
- }
- 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)
- {
- if (errno == EINTR)
- return MHD_YES;
- MHD_DLOG (daemon, "Select failed: %s\n", STRERROR (errno));
- return MHD_NO;
- }
- ds = daemon->socket_fd;
- if (ds == -1)
- return MHD_YES;
- if (FD_ISSET (ds, &rs))
- {
- MHD_accept_connection (daemon);
- go_again = MHD_YES;
- }
- if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
- {
- /* do not have a thread per connection, process all connections now
*/
- now = time (NULL);
- pos = daemon->connections;
- while (pos != NULL)
- {
- ds = pos->socket_fd;
- if (ds != -1)
- {
- if (FD_ISSET (ds, &rs))
- {
- pos->last_activity = now;
- MHD_connection_handle_read (pos);
- }
- if (FD_ISSET (ds, &ws))
- {
- pos->last_activity = now;
- MHD_connection_handle_write (pos);
- }
- }
- pos = pos->next;
- }
- }
+ /* single-threaded, go over everything */
+ if (MHD_NO == MHD_get_fdset (daemon, &rs, &ws, &es, &max))
+ return MHD_NO;
}
+ else
+ {
+ /* accept only, have one thread per connection */
+ max = daemon->socket_fd;
+ if (max == -1)
+ return MHD_NO;
+ FD_SET (max, &rs);
+ }
+ if (may_block == MHD_NO)
+ {
+ timeout.tv_usec = 0;
+ timeout.tv_sec = 0;
+ }
+ 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;
+ }
+ }
+ 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)
+ {
+ if (errno == EINTR)
+ return MHD_YES;
+ MHD_DLOG (daemon, "Select failed: %s\n", STRERROR (errno));
+ return MHD_NO;
+ }
+ ds = daemon->socket_fd;
+ if (ds == -1)
+ return MHD_YES;
+ if (FD_ISSET (ds, &rs))
+ MHD_accept_connection (daemon);
+ if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+ {
+ /* do not have a thread per connection, process all connections now */
+ now = time (NULL);
+ pos = daemon->connections;
+ while (pos != NULL)
+ {
+ ds = pos->socket_fd;
+ if (ds != -1)
+ {
+ if (FD_ISSET (ds, &rs))
+ {
+ pos->last_activity = now;
+ MHD_connection_handle_read (pos);
+ }
+ if (FD_ISSET (ds, &ws))
+ {
+ pos->last_activity = now;
+ MHD_connection_handle_write (pos);
+ }
+ }
+ pos = pos->next;
+ }
+ }
return MHD_YES;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5567 - libmicrohttpd/src/daemon,
gnunet <=