]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] ev_* : moved the poll function closer to fd_*
authorWilly Tarreau <w@1wt.eu>
Mon, 9 Apr 2007 07:23:31 +0000 (09:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Apr 2007 07:23:31 +0000 (09:23 +0200)
src/ev_epoll.c
src/ev_poll.c
src/ev_select.c

index 56049bc046777117c03a71f0d85a4447a7e26535..fe0e1a29ed9e86da04c6590c82b6b4b746b97d28 100644 (file)
@@ -96,89 +96,6 @@ REGPRM1 static void __fd_clo(const int fd)
        FD_CLR(fd, old_evts[DIR_WR]);
 }
 
-
-
-/*
- * Initialization of the epoll() poller.
- * Returns 0 in case of failure, non-zero in case of success. If it fails, it
- * disables the poller by setting its pref to 0.
- */
-REGPRM1 static int epoll_init(struct poller *p)
-{
-       __label__ fail_pwevt, fail_prevt, fail_swevt, fail_srevt, fail_ee, fail_fd;
-       int fd_set_bytes;
-
-       p->private = NULL;
-       fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE;
-
-       epoll_fd = epoll_create(global.maxsock + 1);
-       if (epoll_fd < 0)
-               goto fail_fd;
-
-       epoll_events = (struct epoll_event*)
-               calloc(1, sizeof(struct epoll_event) * global.maxsock);
-
-       if (epoll_events == NULL)
-               goto fail_ee;
-
-       if ((old_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_prevt;
-
-       if ((old_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_pwevt;
-               
-       if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_srevt;
-
-       if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_swevt;
-
-       return 1;
-
- fail_swevt:
-       free(fd_evts[DIR_RD]);
- fail_srevt:
-       free(old_evts[DIR_WR]);
- fail_pwevt:
-       free(old_evts[DIR_RD]);
- fail_prevt:
-       free(epoll_events);
- fail_ee:
-       close(epoll_fd);
-       epoll_fd = 0;
- fail_fd:
-       p->pref = 0;
-       return 0;
-}
-
-/*
- * Termination of the epoll() poller.
- * Memory is released and the poller is marked as unselectable.
- */
-REGPRM1 static void epoll_term(struct poller *p)
-{
-       if (fd_evts[DIR_WR])
-               free(fd_evts[DIR_WR]);
-
-       if (fd_evts[DIR_RD])
-               free(fd_evts[DIR_RD]);
-
-       if (old_evts[DIR_WR])
-               free(old_evts[DIR_WR]);
-
-       if (old_evts[DIR_RD])
-               free(old_evts[DIR_RD]);
-
-       if (epoll_events)
-               free(epoll_events);
-
-       close(epoll_fd);
-       epoll_fd = 0;
-
-       p->private = NULL;
-       p->pref = 0;
-}
-
 /*
  * epoll() poller
  */
@@ -296,6 +213,87 @@ REGPRM2 static void epoll_poll(struct poller *p, int wait_time)
        }
 }
 
+/*
+ * Initialization of the epoll() poller.
+ * Returns 0 in case of failure, non-zero in case of success. If it fails, it
+ * disables the poller by setting its pref to 0.
+ */
+REGPRM1 static int epoll_init(struct poller *p)
+{
+       __label__ fail_pwevt, fail_prevt, fail_swevt, fail_srevt, fail_ee, fail_fd;
+       int fd_set_bytes;
+
+       p->private = NULL;
+       fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE;
+
+       epoll_fd = epoll_create(global.maxsock + 1);
+       if (epoll_fd < 0)
+               goto fail_fd;
+
+       epoll_events = (struct epoll_event*)
+               calloc(1, sizeof(struct epoll_event) * global.maxsock);
+
+       if (epoll_events == NULL)
+               goto fail_ee;
+
+       if ((old_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_prevt;
+
+       if ((old_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_pwevt;
+               
+       if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_srevt;
+
+       if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_swevt;
+
+       return 1;
+
+ fail_swevt:
+       free(fd_evts[DIR_RD]);
+ fail_srevt:
+       free(old_evts[DIR_WR]);
+ fail_pwevt:
+       free(old_evts[DIR_RD]);
+ fail_prevt:
+       free(epoll_events);
+ fail_ee:
+       close(epoll_fd);
+       epoll_fd = 0;
+ fail_fd:
+       p->pref = 0;
+       return 0;
+}
+
+/*
+ * Termination of the epoll() poller.
+ * Memory is released and the poller is marked as unselectable.
+ */
+REGPRM1 static void epoll_term(struct poller *p)
+{
+       if (fd_evts[DIR_WR])
+               free(fd_evts[DIR_WR]);
+
+       if (fd_evts[DIR_RD])
+               free(fd_evts[DIR_RD]);
+
+       if (old_evts[DIR_WR])
+               free(old_evts[DIR_WR]);
+
+       if (old_evts[DIR_RD])
+               free(old_evts[DIR_RD]);
+
+       if (epoll_events)
+               free(epoll_events);
+
+       close(epoll_fd);
+       epoll_fd = 0;
+
+       p->private = NULL;
+       p->pref = 0;
+}
+
 /*
  * The only exported function. Returns 1.
  */
index 542742a0c10e710f74acfe163eafeb10553c0ff1..b2010cb28f096faabadf4be534dc18862aa4b244 100644 (file)
@@ -78,60 +78,6 @@ REGPRM1 static void __fd_rem(const int fd)
        FD_CLR(fd, fd_evts[DIR_WR]);
 }
 
-
-
-/*
- * Initialization of the poll() poller.
- * Returns 0 in case of failure, non-zero in case of success. If it fails, it
- * disables the poller by setting its pref to 0.
- */
-REGPRM1 static int poll_init(struct poller *p)
-{
-       __label__ fail_swevt, fail_srevt, fail_pe;
-       int fd_set_bytes;
-
-       p->private = NULL;
-       fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE;
-
-       poll_events = (struct pollfd*)
-               calloc(1, sizeof(struct pollfd) * global.maxsock);
-
-       if (poll_events == NULL)
-               goto fail_pe;
-               
-       if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_srevt;
-
-       if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_swevt;
-
-       return 1;
-
- fail_swevt:
-       free(fd_evts[DIR_RD]);
- fail_srevt:
-       free(poll_events);
- fail_pe:
-       p->pref = 0;
-       return 0;
-}
-
-/*
- * Termination of the poll() poller.
- * Memory is released and the poller is marked as unselectable.
- */
-REGPRM1 static void poll_term(struct poller *p)
-{
-       if (fd_evts[DIR_WR])
-               free(fd_evts[DIR_WR]);
-       if (fd_evts[DIR_RD])
-               free(fd_evts[DIR_RD]);
-       if (poll_events)
-               free(poll_events);
-       p->private = NULL;
-       p->pref = 0;
-}
-
 /*
  * Poll() poller
  */
@@ -206,6 +152,58 @@ REGPRM2 static void poll_poll(struct poller *p, int wait_time)
 
 }
 
+/*
+ * Initialization of the poll() poller.
+ * Returns 0 in case of failure, non-zero in case of success. If it fails, it
+ * disables the poller by setting its pref to 0.
+ */
+REGPRM1 static int poll_init(struct poller *p)
+{
+       __label__ fail_swevt, fail_srevt, fail_pe;
+       int fd_set_bytes;
+
+       p->private = NULL;
+       fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE;
+
+       poll_events = (struct pollfd*)
+               calloc(1, sizeof(struct pollfd) * global.maxsock);
+
+       if (poll_events == NULL)
+               goto fail_pe;
+               
+       if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_srevt;
+
+       if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_swevt;
+
+       return 1;
+
+ fail_swevt:
+       free(fd_evts[DIR_RD]);
+ fail_srevt:
+       free(poll_events);
+ fail_pe:
+       p->pref = 0;
+       return 0;
+}
+
+/*
+ * Termination of the poll() poller.
+ * Memory is released and the poller is marked as unselectable.
+ */
+REGPRM1 static void poll_term(struct poller *p)
+{
+       if (fd_evts[DIR_WR])
+               free(fd_evts[DIR_WR]);
+       if (fd_evts[DIR_RD])
+               free(fd_evts[DIR_RD]);
+       if (poll_events)
+               free(poll_events);
+       p->private = NULL;
+       p->pref = 0;
+}
+
 /*
  * The only exported function. Returns 1.
  */
index d019c214791d11c72794039a54785253990a351a..7340d3042fceb217f64be4ec8e48d062812ae4eb 100644 (file)
@@ -76,64 +76,6 @@ REGPRM1 static void __fd_rem(int fd)
        FD_CLR(fd, fd_evts[DIR_WR]);
 }
 
-
-
-/*
- * Initialization of the select() poller.
- * Returns 0 in case of failure, non-zero in case of success. If it fails, it
- * disables the poller by setting its pref to 0.
- */
-REGPRM1 static int select_init(struct poller *p)
-{
-       __label__ fail_swevt, fail_srevt, fail_wevt, fail_revt;
-       int fd_set_bytes;
-
-       p->private = NULL;
-       fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE;
-
-       if ((tmp_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_revt;
-               
-       if ((tmp_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_wevt;
-
-       if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_srevt;
-
-       if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
-               goto fail_swevt;
-
-       return 1;
-
- fail_swevt:
-       free(fd_evts[DIR_RD]);
- fail_srevt:
-       free(tmp_evts[DIR_WR]);
- fail_wevt:
-       free(tmp_evts[DIR_RD]);
- fail_revt:
-       p->pref = 0;
-       return 0;
-}
-
-/*
- * Termination of the select() poller.
- * Memory is released and the poller is marked as unselectable.
- */
-REGPRM1 static void select_term(struct poller *p)
-{
-       if (fd_evts[DIR_WR])
-               free(fd_evts[DIR_WR]);
-       if (fd_evts[DIR_RD])
-               free(fd_evts[DIR_RD]);
-       if (tmp_evts[DIR_WR])
-               free(tmp_evts[DIR_WR]);
-       if (tmp_evts[DIR_RD])
-               free(tmp_evts[DIR_RD]);
-       p->private = NULL;
-       p->pref = 0;
-}
-
 /*
  * Select() poller
  */
@@ -207,6 +149,62 @@ REGPRM2 static void select_poll(struct poller *p, int wait_time)
        }
 }
 
+/*
+ * Initialization of the select() poller.
+ * Returns 0 in case of failure, non-zero in case of success. If it fails, it
+ * disables the poller by setting its pref to 0.
+ */
+REGPRM1 static int select_init(struct poller *p)
+{
+       __label__ fail_swevt, fail_srevt, fail_wevt, fail_revt;
+       int fd_set_bytes;
+
+       p->private = NULL;
+       fd_set_bytes = sizeof(fd_set) * (global.maxsock + FD_SETSIZE - 1) / FD_SETSIZE;
+
+       if ((tmp_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_revt;
+               
+       if ((tmp_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_wevt;
+
+       if ((fd_evts[DIR_RD] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_srevt;
+
+       if ((fd_evts[DIR_WR] = (fd_set *)calloc(1, fd_set_bytes)) == NULL)
+               goto fail_swevt;
+
+       return 1;
+
+ fail_swevt:
+       free(fd_evts[DIR_RD]);
+ fail_srevt:
+       free(tmp_evts[DIR_WR]);
+ fail_wevt:
+       free(tmp_evts[DIR_RD]);
+ fail_revt:
+       p->pref = 0;
+       return 0;
+}
+
+/*
+ * Termination of the select() poller.
+ * Memory is released and the poller is marked as unselectable.
+ */
+REGPRM1 static void select_term(struct poller *p)
+{
+       if (fd_evts[DIR_WR])
+               free(fd_evts[DIR_WR]);
+       if (fd_evts[DIR_RD])
+               free(fd_evts[DIR_RD]);
+       if (tmp_evts[DIR_WR])
+               free(tmp_evts[DIR_WR]);
+       if (tmp_evts[DIR_RD])
+               free(tmp_evts[DIR_RD]);
+       p->private = NULL;
+       p->pref = 0;
+}
+
 /*
  * The only exported function. Returns 1.
  */