mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-04 15:19:52 +00:00
MEDIUM: polling: prepare to call the iocb() function when defined.
We will need this to centralize I/O callbacks. Nobody sets it right now so the code should have no impact.
This commit is contained in:
parent
4e6049e553
commit
9845e75d23
@ -260,15 +260,20 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
if (fdtab[fd].ev & (FD_POLL_IN|FD_POLL_HUP|FD_POLL_ERR))
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
if (fdtab[fd].cb[DIR_RD].f)
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
}
|
||||
|
||||
if ((fd_evts[FD2OFS(fd)] >> FD2BIT(fd)) & DIR2MSK(DIR_WR)) {
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
if (fdtab[fd].ev & (FD_POLL_OUT|FD_POLL_ERR|FD_POLL_HUP))
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
if (fdtab[fd].cb[DIR_WR].f)
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
}
|
||||
|
||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev)
|
||||
fdtab[fd].iocb(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,21 +138,27 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
|
||||
for (count = 0; count < status; count++) {
|
||||
fd = kev[count].ident;
|
||||
|
||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||
if (kev[count].filter == EVFILT_READ) {
|
||||
if (FD_ISSET(fd, fd_evts[DIR_RD])) {
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
fdtab[fd].ev |= FD_POLL_IN;
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
if (fdtab[fd].cb[DIR_RD].f)
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
}
|
||||
} else if (kev[count].filter == EVFILT_WRITE) {
|
||||
if (FD_ISSET(fd, fd_evts[DIR_WR])) {
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
fdtab[fd].ev |= FD_POLL_OUT;
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
if (fdtab[fd].cb[DIR_WR].f)
|
||||
fdtab[fd].cb[DIR_WR].f(fd)
|
||||
}
|
||||
}
|
||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev)
|
||||
fdtab[fd].iocb(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,15 +163,20 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
if (fdtab[fd].ev & (FD_POLL_IN|FD_POLL_HUP|FD_POLL_ERR))
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
if (fdtab[fd].cb[DIR_RD].f)
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
}
|
||||
|
||||
if (FD_ISSET(fd, fd_evts[DIR_WR])) {
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
if (fdtab[fd].ev & (FD_POLL_OUT|FD_POLL_ERR|FD_POLL_HUP))
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
if (fdtab[fd].cb[DIR_WR].f)
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
}
|
||||
|
||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev)
|
||||
fdtab[fd].iocb(fd);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -146,19 +146,25 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
/* if we specify read first, the accepts and zero reads will be
|
||||
* seen first. Moreover, system buffers will be flushed faster.
|
||||
*/
|
||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||
if (FD_ISSET(fd, tmp_evts[DIR_RD])) {
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
fdtab[fd].ev |= FD_POLL_IN;
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
if (fdtab[fd].cb[DIR_RD].f)
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
}
|
||||
|
||||
if (FD_ISSET(fd, tmp_evts[DIR_WR])) {
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
fdtab[fd].ev |= FD_POLL_OUT;
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
if (fdtab[fd].cb[DIR_WR].f)
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
}
|
||||
|
||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev)
|
||||
fdtab[fd].iocb(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,15 +413,20 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
if (fdtab[fd].ev & (FD_POLL_IN|FD_POLL_HUP|FD_POLL_ERR))
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
if (fdtab[fd].cb[DIR_RD].f)
|
||||
fdtab[fd].cb[DIR_RD].f(fd);
|
||||
}
|
||||
|
||||
if ((fdtab[fd].spec.e & FD_EV_MASK_W) == FD_EV_WAIT_W) {
|
||||
if (!fdtab[fd].owner)
|
||||
continue;
|
||||
if (fdtab[fd].ev & (FD_POLL_OUT|FD_POLL_ERR))
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
if (fdtab[fd].cb[DIR_WR].f)
|
||||
fdtab[fd].cb[DIR_WR].f(fd);
|
||||
}
|
||||
|
||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev)
|
||||
fdtab[fd].iocb(fd);
|
||||
}
|
||||
|
||||
/* now process speculative events if any */
|
||||
@ -454,7 +459,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
/* The owner is interested in reading from this FD */
|
||||
/* Pretend there is something to read */
|
||||
fdtab[fd].ev |= FD_POLL_IN;
|
||||
if (!fdtab[fd].cb[DIR_RD].f(fd))
|
||||
if (fdtab[fd].cb[DIR_RD].f && !fdtab[fd].cb[DIR_RD].f(fd))
|
||||
fdtab[fd].spec.e ^= (FD_EV_WAIT_R ^ FD_EV_SPEC_R);
|
||||
}
|
||||
|
||||
@ -462,7 +467,21 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
||||
/* The owner is interested in writing to this FD */
|
||||
/* Pretend there is something to write */
|
||||
fdtab[fd].ev |= FD_POLL_OUT;
|
||||
if (!fdtab[fd].cb[DIR_WR].f(fd))
|
||||
if (fdtab[fd].cb[DIR_WR].f && !fdtab[fd].cb[DIR_WR].f(fd))
|
||||
fdtab[fd].spec.e ^= (FD_EV_WAIT_W ^ FD_EV_SPEC_W);
|
||||
}
|
||||
|
||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev) {
|
||||
int wait = fdtab[fd].iocb(fd);
|
||||
|
||||
/* FIXME: warning, this will not work if both old and new
|
||||
* callbacks are used at the same time ! This is only a
|
||||
* temporary measure during the migration.
|
||||
*/
|
||||
if (wait & FD_WAIT_READ)
|
||||
fdtab[fd].spec.e ^= (FD_EV_WAIT_R ^ FD_EV_SPEC_R);
|
||||
|
||||
if (wait & FD_WAIT_WRITE)
|
||||
fdtab[fd].spec.e ^= (FD_EV_WAIT_W ^ FD_EV_SPEC_W);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user