]> jfr.im git - solanum.git/blobdiff - libcharybdis/kqueue.c
[svn] Our way of using kqueue may cause it to report fds we
[solanum.git] / libcharybdis / kqueue.c
index 327ca9fecb177524231aa0ec8c2bba995299d250..53dcdb4751780061cd36fd30f99d6719dddb7b1b 100644 (file)
@@ -22,7 +22,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: kqueue.c 3205 2007-02-09 22:18:23Z nenolod $
+ *  $Id: kqueue.c 3241 2007-03-05 17:52:28Z jilles $
  */
 
 #include "stdinc.h"
@@ -156,7 +156,7 @@ void
 comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
               void *client_data, time_t timeout)
 {
-       fde_t *F = &fd_table[fd];
+       fde_t *F = comm_locate_fd(fd);
        s_assert(fd >= 0);
        s_assert(F->flags.open);
 
@@ -239,7 +239,7 @@ comm_select(unsigned long delay)
        {
                int fd = (int) ke[i].ident;
                PF *hdl = NULL;
-               fde_t *F = &fd_table[fd];
+               fde_t *F = comm_locate_fd(fd);
 
                if(ke[i].flags & EV_ERROR)
                {
@@ -247,6 +247,13 @@ comm_select(unsigned long delay)
                        /* XXX error == bad! -- adrian */
                        continue;       /* XXX! */
                }
+               if (F == NULL)
+               {
+                       /* XXX this is because of our "queueing" of
+                        * kqueue changes so we may get ones for fds
+                        * we have already closed? -- jilles */
+                       continue;
+               }
 
                switch (ke[i].filter)
                {