Explorar el Código

handle case where poll/select have nothing left to do

Christian Grothoff hace 12 años
padre
commit
762856de2c
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      src/daemon/daemon.c

+ 6 - 0
src/daemon/daemon.c

@@ -1468,6 +1468,8 @@ MHD_select (struct MHD_Daemon *daemon,
       timeout.tv_sec = ltimeout / 1000;
       tv = &timeout;
     }
+  if (-1 == max)
+    return MHD_YES;
   num_ready = SELECT (max + 1, &rs, &ws, &es, tv);
   if (MHD_YES == daemon->shutdown)
     return MHD_NO;
@@ -1555,6 +1557,8 @@ MHD_poll_all (struct MHD_Daemon *daemon,
 	  p[poll_server+i].events |= POLLOUT;
 	i++;
       }
+    if (0 == poll_server + num_connections)
+      return MHD_YES;
     if (poll (p, poll_server + num_connections, timeout) < 0) 
       {
 	if (EINTR == errno)
@@ -1635,6 +1639,8 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
     timeout = 0;
   else
     timeout = -1;
+  if (0 == poll_count)
+    return MHD_YES;
   if (poll (p, poll_count, timeout) < 0)
     {
       if (EINTR == errno)