]> git.saurik.com Git - redis.git/blobdiff - ae.c
REDIS_MAX_COMPLETED_JOBS_PROCESSED is now in percentage, not number of jobs. Moved...
[redis.git] / ae.c
diff --git a/ae.c b/ae.c
index 4f12e4109e8e11f8cb70ac3203c802bfbc9a7a3a..25e55fdefba1722f352fff6a19fad40eba7cec18 100644 (file)
--- a/ae.c
+++ b/ae.c
 #ifdef HAVE_EPOLL
 #include "ae_epoll.c"
 #else
-#include "ae_select.c"
+    #ifdef HAVE_KQUEUE
+    #include "ae_kqueue.c"
+    #else
+    #include "ae_select.c"
+    #endif
 #endif
 
 aeEventLoop *aeCreateEventLoop(void) {
@@ -89,7 +93,6 @@ int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
     fe->mask |= mask;
     if (mask & AE_READABLE) fe->rfileProc = proc;
     if (mask & AE_WRITABLE) fe->wfileProc = proc;
-    if (mask & AE_EXCEPTION) fe->efileProc = proc;
     fe->clientData = clientData;
     if (fd > eventLoop->maxfd)
         eventLoop->maxfd = fd;
@@ -321,18 +324,19 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
             aeFileEvent *fe = &eventLoop->events[eventLoop->fired[j].fd];
             int mask = eventLoop->fired[j].mask;
             int fd = eventLoop->fired[j].fd;
+            int rfired = 0;
 
            /* note the fe->mask & mask & ... code: maybe an already processed
              * event removed an element that fired and we still didn't
              * processed, so we check if the event is still valid. */
-            if (fe->mask & mask & AE_READABLE)
+            if (fe->mask & mask & AE_READABLE) {
+                rfired = 1;
                 fe->rfileProc(eventLoop,fd,fe->clientData,mask);
-            if (fe->mask & mask & AE_WRITABLE && fe->wfileProc != fe->rfileProc)
-                fe->wfileProc(eventLoop,fd,fe->clientData,mask);
-            if (fe->mask & mask & AE_EXCEPTION &&
-                                      fe->efileProc != fe->wfileProc &&
-                                       fe->efileProc != fe->rfileProc)
-                fe->efileProc(eventLoop,fd,fe->clientData,mask);
+            }
+            if (fe->mask & mask & AE_WRITABLE) {
+                if (!rfired || fe->wfileProc != fe->rfileProc)
+                    fe->wfileProc(eventLoop,fd,fe->clientData,mask);
+            }
             processed++;
         }
     }
@@ -358,20 +362,21 @@ int aeWait(int fd, int mask, long long milliseconds) {
 
     if (mask & AE_READABLE) FD_SET(fd,&rfds);
     if (mask & AE_WRITABLE) FD_SET(fd,&wfds);
-    if (mask & AE_EXCEPTION) FD_SET(fd,&efds);
     if ((retval = select(fd+1, &rfds, &wfds, &efds, &tv)) > 0) {
         if (FD_ISSET(fd,&rfds)) retmask |= AE_READABLE;
         if (FD_ISSET(fd,&wfds)) retmask |= AE_WRITABLE;
-        if (FD_ISSET(fd,&efds)) retmask |= AE_EXCEPTION;
         return retmask;
     } else {
         return retval;
     }
 }
 
-void aeMain(aeEventLoop *eventLoop)
-{
+void aeMain(aeEventLoop *eventLoop) {
     eventLoop->stop = 0;
     while (!eventLoop->stop)
         aeProcessEvents(eventLoop, AE_ALL_EVENTS);
 }
+
+char *aeGetApiName(void) {
+    return aeApiName();
+}