]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: fd: centralize the processing of speculative events
authorWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2012 15:43:45 +0000 (16:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2012 16:45:39 +0000 (17:45 +0100)
Speculative events are independant on the poller, so they can be
centralized in fd.c.

include/proto/fd.h
src/ev_sepoll.c
src/fd.c
src/haproxy.c

index 5923278146c7fe5d8a7fedb25deb0720869c56b3..e72c43ff8dd92b78a756592c19144051327852bb 100644 (file)
@@ -76,6 +76,11 @@ int list_pollers(FILE *out);
  */
 void run_poller();
 
+/* Scan and process the speculative events. This should be called right after
+ * the poller.
+ */
+void fd_process_spec_events();
+
 /* Mark fd <fd> as updated and allocate an entry in the update list for this if
  * it was not already there. This can be done at any time.
  */
index c5b2a6e7ab520959f2b01fbcae29914ccd0125f9..71e401440040f26d67b2815cde21af901dc314ff 100644 (file)
@@ -48,7 +48,6 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
        int status, eo, en;
        int fd, opcode;
        int count;
-       int spec_idx;
        int updt_idx;
        int wait_time;
 
@@ -207,42 +206,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                }
        }
 
-       /* now process speculative events if any */
-
-       for (spec_idx = 0; spec_idx < fd_nbspec; ) {
-               fd = fd_spec[spec_idx];
-               eo = fdtab[fd].spec_e;
-
-               /*
-                * Process the speculative events.
-                *
-                * Principle: events which are marked FD_EV_ACTIVE are processed
-                * with their usual I/O callback. The callback may remove the
-                * events from the list or tag them for polling. Changes will be
-                * applied on next round.
-                */
-
-               fdtab[fd].ev &= FD_POLL_STICKY;
-
-               if ((eo & FD_EV_STATUS_R) == FD_EV_ACTIVE_R)
-                       fdtab[fd].ev |= FD_POLL_IN;
-
-               if ((eo & FD_EV_STATUS_W) == FD_EV_ACTIVE_W)
-                       fdtab[fd].ev |= FD_POLL_OUT;
-
-               if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev)
-                       fdtab[fd].iocb(fd);
-
-               /* if the fd was removed from the spec list, it has been
-                * replaced by the next one that we don't want to skip !
-                */
-               if (spec_idx < fd_nbspec && fd_spec[spec_idx] != fd)
-                       continue;
-
-               spec_idx++;
-       }
-
-       /* in the end, we have processed status + spec_processed FDs */
+       /* the caller will take care of speculative events */
 }
 
 /*
index 2718748114264faf4b5c54e18ffd9e5f51e9ed34..ac6ec5f416741dec7c2c8e8ba3dd4af375ad34cd 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -132,6 +132,48 @@ void fd_delete(int fd)
                maxfd--;
 }
 
+/* Scan and process the speculative events. This should be called right after
+ * the poller.
+ */
+void fd_process_spec_events()
+{
+       int fd, spec_idx, e;
+
+       /* now process speculative events if any */
+
+       for (spec_idx = 0; spec_idx < fd_nbspec; ) {
+               fd = fd_spec[spec_idx];
+               e = fdtab[fd].spec_e;
+
+               /*
+                * Process the speculative events.
+                *
+                * Principle: events which are marked FD_EV_ACTIVE are processed
+                * with their usual I/O callback. The callback may remove the
+                * events from the list or tag them for polling. Changes will be
+                * applied on next round.
+                */
+
+               fdtab[fd].ev &= FD_POLL_STICKY;
+
+               if ((e & FD_EV_STATUS_R) == FD_EV_ACTIVE_R)
+                       fdtab[fd].ev |= FD_POLL_IN;
+
+               if ((e & FD_EV_STATUS_W) == FD_EV_ACTIVE_W)
+                       fdtab[fd].ev |= FD_POLL_OUT;
+
+               if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev)
+                       fdtab[fd].iocb(fd);
+
+               /* if the fd was removed from the spec list, it has been
+                * replaced by the next one that we don't want to skip !
+                */
+               if (spec_idx < fd_nbspec && fd_spec[spec_idx] != fd)
+                       continue;
+
+               spec_idx++;
+       }
+}
 
 /* disable the specified poller */
 void disable_poller(const char *poller_name)
index d973ae282eb05dc98c3d1e6302e3b071f9426033..1bb65c1cec6af7299728a922f732a397c553833f 100644 (file)
@@ -1216,6 +1216,7 @@ void run_poll_loop()
 
                /* The poller will ensure it returns around <next> */
                cur_poller.poll(&cur_poller, next);
+               fd_process_spec_events();
        }
 }