[Reconnoiter-devel] [reconnoiter commit] r544 - trunk/src/eventer

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Sat Dec 20 10:43:35 EST 2008


Author: jesus
Date: 2008-12-20 10:43:34 -0500 (Sat, 20 Dec 2008)
New Revision: 544

Modified:
   trunk/src/eventer/eventer_kqueue_impl.c
Log:
fixes #68

Modified: trunk/src/eventer/eventer_kqueue_impl.c
===================================================================
--- trunk/src/eventer/eventer_kqueue_impl.c	2008-12-19 19:10:46 UTC (rev 543)
+++ trunk/src/eventer/eventer_kqueue_impl.c	2008-12-20 15:43:34 UTC (rev 544)
@@ -76,7 +76,7 @@
 ke_change (register int const ident,
            register int const filter,
            register int const flags,
-           register void *const udata) {
+           register eventer_t e) {
   register struct kevent *kep;
   KQUEUE_DECL;
   KQUEUE_SETUP;
@@ -93,7 +93,7 @@
   }
   kep = &ke_vec[ke_vec_used++];
 
-  EV_SET(kep, ident, filter, flags, 0, 0, udata);
+  EV_SET(kep, ident, filter, flags, 0, 0, (void *)e->fd);
   if(kqs == master_kqs) pthread_mutex_unlock(&kqs_lock);
 }
 
@@ -180,6 +180,7 @@
   if(e->mask & (EVENTER_READ | EVENTER_WRITE | EVENTER_EXCEPTION)) {
     ev_lock_state_t lockstate;
     lockstate = acquire_master_fd(e->fd);
+    noitL(eventer_deb, "kqueue: remove(%d)\n", e->fd);
     if(e == master_fds[e->fd].e) {
       removed = e;
       master_fds[e->fd].e = NULL;
@@ -187,7 +188,8 @@
         ke_change(e->fd, EVFILT_READ, EV_DELETE | EV_DISABLE, e);
       if(e->mask & (EVENTER_WRITE))
         ke_change(e->fd, EVFILT_WRITE, EV_DELETE | EV_DISABLE, e);
-    }
+    } else
+      noitL(eventer_deb, "kqueue: remove(%d) failed.\n", e->fd);
     release_master_fd(e->fd, lockstate);
   }
   else if(e->mask & EVENTER_TIMER) {
@@ -214,6 +216,7 @@
     pthread_mutex_unlock(&te_lock);
     return;
   }
+  noitL(eventer_deb, "kqueue: update(%d, %x->%x)\n", e->fd, e->mask, mask);
   /* Disable old, if they aren't active in the new */
   if((e->mask & (EVENTER_READ | EVENTER_EXCEPTION)) &&
      !(mask & (EVENTER_READ | EVENTER_EXCEPTION)))
@@ -237,6 +240,7 @@
   eventer_t eiq = NULL;
   ev_lock_state_t lockstate;
   if(master_fds[fd].e) {
+    noitL(eventer_deb, "kqueue: remove_fd(%d)\n", fd);
     lockstate = acquire_master_fd(fd);
     eiq = master_fds[fd].e;
     master_fds[fd].e = NULL;
@@ -441,8 +445,9 @@
                    (int)ke->ident, strerror(ke->data));
           continue;
         }
-        e = (eventer_t)ke->udata;
+        assert((int)ke->udata == ke->ident);
         fd = ke->ident;
+        e = master_fds[fd].e;
         /* If we've seen this fd, don't callback twice */
         if(!masks[fd]) continue;
         /* It's possible that someone removed the event and freed it



More information about the Reconnoiter-devel mailing list