]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - libcharybdis/commio.c
[svn] Repair operspy who !#channel, broken by me in r3283.
[irc/rqf/shadowircd.git] / libcharybdis / commio.c
index c30322d5285ca9fbe052b453c5a2073d210864aa..2985fc2f001320bd3ac786300ca96f96b146329c 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: commio.c 3229 2007-03-05 17:23:07Z nenolod $
+ *  $Id: commio.c 3247 2007-03-05 18:42:24Z nenolod $
  */
 
 #include "libcharybdis.h"
@@ -317,39 +317,51 @@ comm_setflush(int fd, time_t timeout, PF * callback, void *cbdata)
 void
 comm_checktimeouts(void *notused)
 {
-       int fd;
        PF *hdl;
        void *data;
        fde_t *F;
-       for (fd = 0; fd <= highest_fd; fd++)
+       dlink_list *bucket;
+       int i;
+       dlink_node *n, *n2;
+
+       for (i = 0; i <= FD_HASH_SIZE; i++)
        {
-               F = comm_locate_fd(fd);
-               if(F == NULL)
-                       continue;
-               if(!F->flags.open)
-                       continue;
-               if(F->flags.closing)
+               bucket = &fd_table[i];
+
+               if (dlink_list_length(bucket) <= 0)
                        continue;
 
-               /* check flush functions */
-               if(F->flush_handler &&
-                  F->flush_timeout > 0 && F->flush_timeout < CurrentTime)
+               DLINK_FOREACH_SAFE(n, n2, bucket->head)
                {
-                       hdl = F->flush_handler;
-                       data = F->flush_data;
-                       comm_setflush(F->fd, 0, NULL, NULL);
-                       hdl(F->fd, data);
-               }
+                       F = (fde_t *) n->data;
 
-               /* check timeouts */
-               if(F->timeout_handler &&
-                  F->timeout > 0 && F->timeout < CurrentTime)
-               {
-                       /* Call timeout handler */
-                       hdl = F->timeout_handler;
-                       data = F->timeout_data;
-                       comm_settimeout(F->fd, 0, NULL, NULL);
-                       hdl(F->fd, data);
+                       if(F == NULL)
+                               continue;
+                       if(!F->flags.open)
+                               continue;
+                       if(F->flags.closing)
+                               continue;
+
+                       /* check flush functions */
+                       if(F->flush_handler &&
+                          F->flush_timeout > 0 && F->flush_timeout < CurrentTime)
+                       {
+                               hdl = F->flush_handler;
+                               data = F->flush_data;
+                               comm_setflush(F->fd, 0, NULL, NULL);
+                               hdl(F->fd, data);
+                       }
+
+                       /* check timeouts */
+                       if(F->timeout_handler &&
+                          F->timeout > 0 && F->timeout < CurrentTime)
+                       {
+                               /* Call timeout handler */
+                               hdl = F->timeout_handler;
+                               data = F->timeout_data;
+                               comm_settimeout(F->fd, 0, NULL, NULL);
+                               hdl(F->fd, data);
+                       }
                }
        }
 }
@@ -728,7 +740,7 @@ fdlist_update_biggest(int fd, int opening)
         * re-opening it
         */
        s_assert(!opening);
-       while (highest_fd >= 0 && comm_locate_fd(fd)->flags.open) /* XXX */
+       while (highest_fd >= 0 && comm_locate_fd(fd) != NULL)
                highest_fd--;
 }
 
@@ -789,6 +801,7 @@ comm_close(int fd)
        }
        comm_setselect(F->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
        comm_setflush(F->fd, 0, NULL, NULL);
+       F->timeout = 0;
        
        if (F->dns_query != NULL)
        {
@@ -802,7 +815,6 @@ comm_close(int fd)
        number_fd--;
        comm_remove_fd(fd);
 
-       F->timeout = 0;
        /* Unlike squid, we're actually closing the FD here! -- adrian */
        close(fd);
 }