1
0
mirror of http://git.haproxy.org/git/haproxy.git/ synced 2025-04-18 13:05:38 +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:
Willy Tarreau 2012-07-06 11:44:28 +02:00 committed by Willy Tarreau
parent 4e6049e553
commit 9845e75d23
5 changed files with 53 additions and 12 deletions

View File

@ -260,6 +260,7 @@ 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))
if (fdtab[fd].cb[DIR_RD].f)
fdtab[fd].cb[DIR_RD].f(fd);
}
@ -267,8 +268,12 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
if (!fdtab[fd].owner)
continue;
if (fdtab[fd].ev & (FD_POLL_OUT|FD_POLL_ERR|FD_POLL_HUP))
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);
}
}

View File

@ -138,11 +138,14 @@ 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;
if (fdtab[fd].cb[DIR_RD].f)
fdtab[fd].cb[DIR_RD].f(fd);
}
} else if (kev[count].filter == EVFILT_WRITE) {
@ -150,9 +153,12 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
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);
}
}

View File

@ -163,6 +163,7 @@ 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))
if (fdtab[fd].cb[DIR_RD].f)
fdtab[fd].cb[DIR_RD].f(fd);
}
@ -170,8 +171,12 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
if (!fdtab[fd].owner)
continue;
if (fdtab[fd].ev & (FD_POLL_OUT|FD_POLL_ERR|FD_POLL_HUP))
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);
}
}

View File

@ -146,10 +146,12 @@ 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;
if (fdtab[fd].cb[DIR_RD].f)
fdtab[fd].cb[DIR_RD].f(fd);
}
@ -157,8 +159,12 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
if (!fdtab[fd].owner)
continue;
fdtab[fd].ev |= FD_POLL_OUT;
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);
}
}
}

View File

@ -413,6 +413,7 @@ 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))
if (fdtab[fd].cb[DIR_RD].f)
fdtab[fd].cb[DIR_RD].f(fd);
}
@ -420,8 +421,12 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
if (!fdtab[fd].owner)
continue;
if (fdtab[fd].ev & (FD_POLL_OUT|FD_POLL_ERR))
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);
}