Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 1 | /* |
| 2 | * FD polling functions for generic poll() |
| 3 | * |
Willy Tarreau | f817e9f | 2014-01-10 16:58:45 +0100 | [diff] [blame] | 4 | * Copyright 2000-2014 Willy Tarreau <w@1wt.eu> |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
Willy Tarreau | 3c8a896 | 2017-03-13 17:14:51 +0100 | [diff] [blame] | 13 | #define _GNU_SOURCE // for POLLRDHUP on Linux |
| 14 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 15 | #include <unistd.h> |
Willy Tarreau | 3c8a896 | 2017-03-13 17:14:51 +0100 | [diff] [blame] | 16 | #include <poll.h> |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 17 | #include <sys/time.h> |
| 18 | #include <sys/types.h> |
| 19 | |
| 20 | #include <common/compat.h> |
| 21 | #include <common/config.h> |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 22 | #include <common/ticks.h> |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 23 | #include <common/time.h> |
| 24 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 25 | #include <types/global.h> |
| 26 | |
| 27 | #include <proto/fd.h> |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 28 | |
Willy Tarreau | 3c8a896 | 2017-03-13 17:14:51 +0100 | [diff] [blame] | 29 | |
| 30 | #ifndef POLLRDHUP |
| 31 | /* POLLRDHUP was defined late in libc, and it appeared in kernel 2.6.17 */ |
| 32 | #define POLLRDHUP 0 |
| 33 | #endif |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 34 | |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 35 | static unsigned int *fd_evts[2]; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 36 | |
| 37 | /* private data */ |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 38 | static THREAD_LOCAL int nbfd = 0; |
| 39 | static THREAD_LOCAL struct pollfd *poll_events = NULL; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 40 | |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 41 | static inline void hap_fd_set(int fd, unsigned int *evts) |
| 42 | { |
| 43 | evts[fd / (8*sizeof(*evts))] |= 1U << (fd & (8*sizeof(*evts) - 1)); |
| 44 | } |
| 45 | |
| 46 | static inline void hap_fd_clr(int fd, unsigned int *evts) |
| 47 | { |
| 48 | evts[fd / (8*sizeof(*evts))] &= ~(1U << (fd & (8*sizeof(*evts) - 1))); |
| 49 | } |
| 50 | |
| 51 | REGPRM1 static void __fd_clo(int fd) |
| 52 | { |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 53 | HA_SPIN_LOCK(POLL_LOCK, &poll_lock); |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 54 | hap_fd_clr(fd, fd_evts[DIR_RD]); |
| 55 | hap_fd_clr(fd, fd_evts[DIR_WR]); |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 56 | HA_SPIN_UNLOCK(POLL_LOCK, &poll_lock); |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 57 | } |
| 58 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 59 | /* |
| 60 | * Poll() poller |
| 61 | */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 62 | REGPRM2 static void _do_poll(struct poller *p, int exp) |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 63 | { |
| 64 | int status; |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 65 | int fd; |
Willy Tarreau | d825eef | 2007-05-12 22:35:00 +0200 | [diff] [blame] | 66 | int wait_time; |
Willy Tarreau | cc7e3f7 | 2012-11-11 17:25:15 +0100 | [diff] [blame] | 67 | int updt_idx, en, eo; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 68 | int fds, count; |
| 69 | int sr, sw; |
| 70 | unsigned rn, wn; /* read new, write new */ |
| 71 | |
Willy Tarreau | cc7e3f7 | 2012-11-11 17:25:15 +0100 | [diff] [blame] | 72 | /* first, scan the update list to find changes */ |
| 73 | for (updt_idx = 0; updt_idx < fd_nbupdt; updt_idx++) { |
| 74 | fd = fd_updt[updt_idx]; |
Willy Tarreau | cc7e3f7 | 2012-11-11 17:25:15 +0100 | [diff] [blame] | 75 | |
Willy Tarreau | f817e9f | 2014-01-10 16:58:45 +0100 | [diff] [blame] | 76 | if (!fdtab[fd].owner) |
| 77 | continue; |
Willy Tarreau | cc7e3f7 | 2012-11-11 17:25:15 +0100 | [diff] [blame] | 78 | |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 79 | HA_SPIN_LOCK(FD_LOCK, &fdtab[fd].lock); |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 80 | fdtab[fd].updated = 0; |
| 81 | fdtab[fd].new = 0; |
| 82 | |
Willy Tarreau | 25002d2 | 2014-01-25 10:32:56 +0100 | [diff] [blame] | 83 | eo = fdtab[fd].state; |
| 84 | en = fd_compute_new_polled_status(eo); |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 85 | fdtab[fd].state = en; |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 86 | HA_SPIN_UNLOCK(FD_LOCK, &fdtab[fd].lock); |
Willy Tarreau | f817e9f | 2014-01-10 16:58:45 +0100 | [diff] [blame] | 87 | |
| 88 | if ((eo ^ en) & FD_EV_POLLED_RW) { |
| 89 | /* poll status changed, update the lists */ |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 90 | HA_SPIN_LOCK(POLL_LOCK, &poll_lock); |
Willy Tarreau | f817e9f | 2014-01-10 16:58:45 +0100 | [diff] [blame] | 91 | if ((eo & ~en) & FD_EV_POLLED_R) |
| 92 | hap_fd_clr(fd, fd_evts[DIR_RD]); |
| 93 | else if ((en & ~eo) & FD_EV_POLLED_R) |
| 94 | hap_fd_set(fd, fd_evts[DIR_RD]); |
| 95 | |
| 96 | if ((eo & ~en) & FD_EV_POLLED_W) |
| 97 | hap_fd_clr(fd, fd_evts[DIR_WR]); |
| 98 | else if ((en & ~eo) & FD_EV_POLLED_W) |
| 99 | hap_fd_set(fd, fd_evts[DIR_WR]); |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 100 | HA_SPIN_UNLOCK(POLL_LOCK, &poll_lock); |
Willy Tarreau | f817e9f | 2014-01-10 16:58:45 +0100 | [diff] [blame] | 101 | } |
Willy Tarreau | cc7e3f7 | 2012-11-11 17:25:15 +0100 | [diff] [blame] | 102 | } |
| 103 | fd_nbupdt = 0; |
| 104 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 105 | nbfd = 0; |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 106 | for (fds = 0; (fds * 8*sizeof(**fd_evts)) < maxfd; fds++) { |
| 107 | rn = fd_evts[DIR_RD][fds]; |
| 108 | wn = fd_evts[DIR_WR][fds]; |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 109 | |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 110 | if (!(rn|wn)) |
| 111 | continue; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 112 | |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 113 | for (count = 0, fd = fds * 8*sizeof(**fd_evts); count < 8*sizeof(**fd_evts) && fd < maxfd; count++, fd++) { |
Christopher Faulet | 63e2ce6 | 2017-06-02 14:36:39 +0200 | [diff] [blame] | 114 | |
Willy Tarreau | f65610a | 2017-10-31 16:06:06 +0100 | [diff] [blame] | 115 | if (!fdtab[fd].owner || !(fdtab[fd].thread_mask & tid_bit)) |
Christopher Faulet | 63e2ce6 | 2017-06-02 14:36:39 +0200 | [diff] [blame] | 116 | continue; |
| 117 | |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 118 | sr = (rn >> count) & 1; |
| 119 | sw = (wn >> count) & 1; |
| 120 | if ((sr|sw)) { |
| 121 | poll_events[nbfd].fd = fd; |
Willy Tarreau | 3c8a896 | 2017-03-13 17:14:51 +0100 | [diff] [blame] | 122 | poll_events[nbfd].events = (sr ? (POLLIN | POLLRDHUP) : 0) | (sw ? POLLOUT : 0); |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 123 | nbfd++; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 124 | } |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 125 | } |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 126 | } |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 127 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 128 | /* now let's wait for events */ |
Willy Tarreau | 10146c9 | 2015-04-13 20:44:19 +0200 | [diff] [blame] | 129 | if (!exp) |
Willy Tarreau | b0b37bc | 2008-06-23 14:00:57 +0200 | [diff] [blame] | 130 | wait_time = MAX_DELAY_MS; |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 131 | else if (tick_is_expired(exp, now_ms)) |
Willy Tarreau | bdefc51 | 2007-05-14 02:02:04 +0200 | [diff] [blame] | 132 | wait_time = 0; |
Willy Tarreau | b0b37bc | 2008-06-23 14:00:57 +0200 | [diff] [blame] | 133 | else { |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 134 | wait_time = TICKS_TO_MS(tick_remain(now_ms, exp)) + 1; |
Willy Tarreau | b0b37bc | 2008-06-23 14:00:57 +0200 | [diff] [blame] | 135 | if (wait_time > MAX_DELAY_MS) |
| 136 | wait_time = MAX_DELAY_MS; |
| 137 | } |
Willy Tarreau | d825eef | 2007-05-12 22:35:00 +0200 | [diff] [blame] | 138 | |
Willy Tarreau | 45a1251 | 2011-09-10 16:56:42 +0200 | [diff] [blame] | 139 | gettimeofday(&before_poll, NULL); |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 140 | status = poll(poll_events, nbfd, wait_time); |
Willy Tarreau | b0b37bc | 2008-06-23 14:00:57 +0200 | [diff] [blame] | 141 | tv_update_date(wait_time, status); |
Willy Tarreau | 45a1251 | 2011-09-10 16:56:42 +0200 | [diff] [blame] | 142 | measure_idle(); |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 143 | |
| 144 | for (count = 0; status > 0 && count < nbfd; count++) { |
Christopher Faulet | ab62f51 | 2017-08-30 10:34:36 +0200 | [diff] [blame] | 145 | unsigned int n; |
Willy Tarreau | 491c498 | 2012-07-06 11:16:01 +0200 | [diff] [blame] | 146 | int e = poll_events[count].revents; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 147 | fd = poll_events[count].fd; |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 148 | |
Willy Tarreau | 3c8a896 | 2017-03-13 17:14:51 +0100 | [diff] [blame] | 149 | if (!(e & ( POLLOUT | POLLIN | POLLERR | POLLHUP | POLLRDHUP ))) |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 150 | continue; |
| 151 | |
Willy Tarreau | 076be25 | 2012-07-06 16:02:29 +0200 | [diff] [blame] | 152 | /* ok, we found one active fd */ |
| 153 | status--; |
| 154 | |
| 155 | if (!fdtab[fd].owner) |
| 156 | continue; |
| 157 | |
Willy Tarreau | 462c720 | 2012-12-13 22:26:37 +0100 | [diff] [blame] | 158 | /* it looks complicated but gcc can optimize it away when constants |
| 159 | * have same values... In fact it depends on gcc :-( |
| 160 | */ |
Willy Tarreau | 462c720 | 2012-12-13 22:26:37 +0100 | [diff] [blame] | 161 | if (POLLIN == FD_POLL_IN && POLLOUT == FD_POLL_OUT && |
| 162 | POLLERR == FD_POLL_ERR && POLLHUP == FD_POLL_HUP) { |
Christopher Faulet | ab62f51 | 2017-08-30 10:34:36 +0200 | [diff] [blame] | 163 | n = e & (POLLIN|POLLOUT|POLLERR|POLLHUP); |
Willy Tarreau | 462c720 | 2012-12-13 22:26:37 +0100 | [diff] [blame] | 164 | } |
| 165 | else { |
Christopher Faulet | ab62f51 | 2017-08-30 10:34:36 +0200 | [diff] [blame] | 166 | n = ((e & POLLIN ) ? FD_POLL_IN : 0) | |
Willy Tarreau | 462c720 | 2012-12-13 22:26:37 +0100 | [diff] [blame] | 167 | ((e & POLLOUT) ? FD_POLL_OUT : 0) | |
| 168 | ((e & POLLERR) ? FD_POLL_ERR : 0) | |
| 169 | ((e & POLLHUP) ? FD_POLL_HUP : 0); |
| 170 | } |
Willy Tarreau | 491c498 | 2012-07-06 11:16:01 +0200 | [diff] [blame] | 171 | |
Willy Tarreau | 3c8a896 | 2017-03-13 17:14:51 +0100 | [diff] [blame] | 172 | /* always remap RDHUP to HUP as they're used similarly */ |
| 173 | if (e & POLLRDHUP) { |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 174 | HA_ATOMIC_OR(&cur_poller.flags, HAP_POLL_F_RDHUP); |
Christopher Faulet | ab62f51 | 2017-08-30 10:34:36 +0200 | [diff] [blame] | 175 | n |= FD_POLL_HUP; |
Willy Tarreau | 3c8a896 | 2017-03-13 17:14:51 +0100 | [diff] [blame] | 176 | } |
Christopher Faulet | ab62f51 | 2017-08-30 10:34:36 +0200 | [diff] [blame] | 177 | fd_update_events(fd, n); |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 178 | } |
| 179 | |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 180 | } |
| 181 | |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 182 | |
| 183 | static int init_poll_per_thread() |
| 184 | { |
| 185 | poll_events = calloc(1, sizeof(struct pollfd) * global.maxsock); |
| 186 | if (poll_events == NULL) |
| 187 | return 0; |
| 188 | return 1; |
| 189 | } |
| 190 | |
| 191 | static void deinit_poll_per_thread() |
| 192 | { |
| 193 | free(poll_events); |
Christopher Faulet | cd7879a | 2017-10-27 13:53:47 +0200 | [diff] [blame] | 194 | poll_events = NULL; |
Christopher Faulet | d4604ad | 2017-05-29 10:40:41 +0200 | [diff] [blame] | 195 | } |
| 196 | |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 197 | /* |
| 198 | * Initialization of the poll() poller. |
| 199 | * Returns 0 in case of failure, non-zero in case of success. If it fails, it |
| 200 | * disables the poller by setting its pref to 0. |
| 201 | */ |
Willy Tarreau | ef1d1f8 | 2007-04-16 00:25:25 +0200 | [diff] [blame] | 202 | REGPRM1 static int _do_init(struct poller *p) |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 203 | { |
Christopher Faulet | cd7879a | 2017-10-27 13:53:47 +0200 | [diff] [blame] | 204 | __label__ fail_swevt, fail_srevt; |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 205 | int fd_evts_bytes; |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 206 | |
| 207 | p->private = NULL; |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 208 | fd_evts_bytes = (global.maxsock + sizeof(**fd_evts) - 1) / sizeof(**fd_evts) * sizeof(**fd_evts); |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 209 | |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 210 | if ((fd_evts[DIR_RD] = calloc(1, fd_evts_bytes)) == NULL) |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 211 | goto fail_srevt; |
Willy Tarreau | 80da05a | 2013-03-31 14:06:57 +0200 | [diff] [blame] | 212 | if ((fd_evts[DIR_WR] = calloc(1, fd_evts_bytes)) == NULL) |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 213 | goto fail_swevt; |
| 214 | |
Christopher Faulet | cd7879a | 2017-10-27 13:53:47 +0200 | [diff] [blame] | 215 | hap_register_per_thread_init(init_poll_per_thread); |
| 216 | hap_register_per_thread_deinit(deinit_poll_per_thread); |
| 217 | |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 218 | return 1; |
| 219 | |
| 220 | fail_swevt: |
| 221 | free(fd_evts[DIR_RD]); |
| 222 | fail_srevt: |
| 223 | free(poll_events); |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 224 | p->pref = 0; |
| 225 | return 0; |
| 226 | } |
| 227 | |
| 228 | /* |
| 229 | * Termination of the poll() poller. |
| 230 | * Memory is released and the poller is marked as unselectable. |
| 231 | */ |
Willy Tarreau | ef1d1f8 | 2007-04-16 00:25:25 +0200 | [diff] [blame] | 232 | REGPRM1 static void _do_term(struct poller *p) |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 233 | { |
Willy Tarreau | a534fea | 2008-08-03 12:19:50 +0200 | [diff] [blame] | 234 | free(fd_evts[DIR_WR]); |
| 235 | free(fd_evts[DIR_RD]); |
Willy Tarreau | e54e917 | 2007-04-09 09:23:31 +0200 | [diff] [blame] | 236 | p->private = NULL; |
| 237 | p->pref = 0; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* |
Willy Tarreau | 2ff7622 | 2007-04-09 19:29:56 +0200 | [diff] [blame] | 241 | * Check that the poller works. |
| 242 | * Returns 1 if OK, otherwise 0. |
| 243 | */ |
Willy Tarreau | ef1d1f8 | 2007-04-16 00:25:25 +0200 | [diff] [blame] | 244 | REGPRM1 static int _do_test(struct poller *p) |
Willy Tarreau | 2ff7622 | 2007-04-09 19:29:56 +0200 | [diff] [blame] | 245 | { |
| 246 | return 1; |
| 247 | } |
| 248 | |
| 249 | /* |
Willy Tarreau | ef1d1f8 | 2007-04-16 00:25:25 +0200 | [diff] [blame] | 250 | * It is a constructor, which means that it will automatically be called before |
| 251 | * main(). This is GCC-specific but it works at least since 2.95. |
| 252 | * Special care must be taken so that it does not need any uninitialized data. |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 253 | */ |
Willy Tarreau | ef1d1f8 | 2007-04-16 00:25:25 +0200 | [diff] [blame] | 254 | __attribute__((constructor)) |
| 255 | static void _do_register(void) |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 256 | { |
Willy Tarreau | ef1d1f8 | 2007-04-16 00:25:25 +0200 | [diff] [blame] | 257 | struct poller *p; |
| 258 | |
| 259 | if (nbpollers >= MAX_POLLERS) |
| 260 | return; |
| 261 | p = &pollers[nbpollers++]; |
| 262 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 263 | p->name = "poll"; |
| 264 | p->pref = 200; |
Willy Tarreau | 5a76769 | 2017-03-13 11:38:28 +0100 | [diff] [blame] | 265 | p->flags = 0; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 266 | p->private = NULL; |
| 267 | |
Willy Tarreau | 70c6fd8 | 2012-11-11 21:02:34 +0100 | [diff] [blame] | 268 | p->clo = __fd_clo; |
Willy Tarreau | ef1d1f8 | 2007-04-16 00:25:25 +0200 | [diff] [blame] | 269 | p->test = _do_test; |
| 270 | p->init = _do_init; |
| 271 | p->term = _do_term; |
| 272 | p->poll = _do_poll; |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | |
| 276 | /* |
| 277 | * Local variables: |
| 278 | * c-indent-level: 8 |
| 279 | * c-basic-offset: 8 |
| 280 | * End: |
| 281 | */ |