Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2006-10-21 15:35:42 UTC

Modified files:
     ChangeLog ircd/engine_kqueue.c

Log message:

Add some comments and remove dead code in engine_kqueue.c

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.819 ircu2.10/ChangeLog:1.820
--- ircu2.10/ChangeLog:1.819    Sun Aug  6 06:18:07 2006
+++ ircu2.10/ChangeLog  Sat Oct 21 08:35:31 2006
@@ -1,3 +1,10 @@
+2006-10-21  Michael Poole <[EMAIL PROTECTED]>
+
+       * ircd/engine_kqueue.c (set_or_clear): Explain in comment why
+       udata can't be used.
+       (engine_delete): Remove unused dellist[] variable and explain
+       why we do not explicitly unregister the fd from kevent.
+
 2006-08-06  Michael Poole <[EMAIL PROTECTED]>
 
        * ircd/m_list.c (param_parse): Ignore 's' and 'S' in the
Index: ircu2.10/ircd/engine_kqueue.c
diff -u ircu2.10/ircd/engine_kqueue.c:1.8 ircu2.10/ircd/engine_kqueue.c:1.9
--- ircu2.10/ircd/engine_kqueue.c:1.8   Tue Mar 22 16:25:16 2005
+++ ircu2.10/ircd/engine_kqueue.c       Sat Oct 21 08:35:32 2006
@@ -18,7 +18,7 @@
  */
 /** @file
  * @brief FreeBSD kqueue()/kevent() event engine.
- * @version $Id: engine_kqueue.c,v 1.8 2005/03/23 00:25:16 entrope Exp $
+ * @version $Id: engine_kqueue.c,v 1.9 2006/10/21 15:35:32 entrope Exp $
  */
 #include "config.h"
 
@@ -173,6 +173,12 @@
     chglist[i].fflags = 0;
     chglist[i].data = 0;
     chglist[i].udata = 0; /* I love udata, but it can't really be used here */
+    /* The reason it cannot be used is that handling an error on the
+     * read or write filter could close the socket after the other
+     * filter was returned in an activity list, so we have to track
+     * active sockets in the sockList array rather than only in
+     * .udata.
+     */
 
     if (set & SOCK_EVENT_READABLE) /* it's set */
       chglist[i].flags |= EV_ENABLE;
@@ -276,27 +282,16 @@
 static void
 engine_delete(struct Socket* sock)
 {
-  struct kevent dellist[2];
-
   assert(0 != sock);
   assert(sock == sockList[s_fd(sock)]);
 
   Debug((DEBUG_ENGINE, "kqueue: Deleting socket %d [%p], state %s",
         s_fd(sock), sock, state_to_name(s_state(sock))));
 
-  dellist[0].ident = s_fd(sock); /* set up the delete list */
-  dellist[0].filter = EVFILT_READ; /* readable filter */
-  dellist[0].flags = EV_DELETE; /* delete it */
-  dellist[0].fflags = 0;
-  dellist[0].data = 0;
-  dellist[0].udata = 0;
-
-  dellist[1].ident = s_fd(sock);
-  dellist[1].filter = EVFILT_WRITE; /* writable filter */
-  dellist[1].flags = EV_DELETE; /* delete it */
-  dellist[1].fflags = 0;
-  dellist[1].data = 0;
-  dellist[1].udata = 0;
+  /* No need to remove it from the kernel - the fds may be closed
+   * already, and the kernel automatically removes fds from the kqueue
+   * when they are closed.  So we just remove it from sockList[].
+   */
 
   sockList[s_fd(sock)] = 0;
 }
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to