mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
[MINOR] changed fd_set*/fd_clr* functions to return ints
The fd_* functions now return ints so that they can be factored when appropriate.
This commit is contained in:
parent
28d86862bc
commit
97129b5408
@ -63,19 +63,21 @@ struct fdtab {
|
|||||||
* poller should set it to 100.
|
* poller should set it to 100.
|
||||||
* - <private> is initialized by the poller's init() function, and cleaned by
|
* - <private> is initialized by the poller's init() function, and cleaned by
|
||||||
* the term() function.
|
* the term() function.
|
||||||
* - cond_s() checks if fd was not set then sets it and returns 1. Otherwise 0.
|
* - cond_s() checks if fd was not set then sets it and returns 1. Otherwise
|
||||||
* - cond_c() checks if fd was set then clears it and returns 1. Otherwise 0.
|
* it returns 0. It may be the same as set().
|
||||||
|
* - cond_c() checks if fd was set then clears it and returns 1. Otherwise
|
||||||
|
* it returns 0. It may be the same as clr().
|
||||||
* - clo() should be used to do indicate the poller that fd will be closed. It
|
* - clo() should be used to do indicate the poller that fd will be closed. It
|
||||||
* may be the same as rem() on some pollers.
|
* may be the same as rem() on some pollers.
|
||||||
* - poll() calls the poller, waiting at most wait_time ms.
|
* - poll() calls the poller, waiting at most wait_time ms.
|
||||||
*/
|
*/
|
||||||
struct poller {
|
struct poller {
|
||||||
void *private; /* any private data for the poller */
|
void *private; /* any private data for the poller */
|
||||||
REGPRM2 int (*isset)(const int fd, const int dir); /* check if <fd> is being polled for dir <dir> */
|
REGPRM2 int (*isset)(const int fd, int dir); /* check if <fd> is being polled for dir <dir> */
|
||||||
REGPRM2 void (*set)(const int fd, const int dir); /* set polling on <fd> for <dir> */
|
REGPRM2 int (*set)(const int fd, int dir); /* set polling on <fd> for <dir> */
|
||||||
REGPRM2 void (*clr)(const int fd, const int dir); /* clear polling on <fd> for <dir> */
|
REGPRM2 int (*clr)(const int fd, int dir); /* clear polling on <fd> for <dir> */
|
||||||
REGPRM2 int (*cond_s)(const int fd, const int dir); /* set polling on <fd> for <dir> if unset */
|
REGPRM2 int (*cond_s)(const int fd, int dir); /* set polling on <fd> for <dir> if unset */
|
||||||
REGPRM2 int (*cond_c)(const int fd, const int dir); /* clear polling on <fd> for <dir> if set */
|
REGPRM2 int (*cond_c)(const int fd, int dir); /* clear polling on <fd> for <dir> if set */
|
||||||
REGPRM1 void (*rem)(const int fd); /* remove any polling on <fd> */
|
REGPRM1 void (*rem)(const int fd); /* remove any polling on <fd> */
|
||||||
REGPRM1 void (*clo)(const int fd); /* mark <fd> as closed */
|
REGPRM1 void (*clo)(const int fd); /* mark <fd> as closed */
|
||||||
REGPRM2 void (*poll)(struct poller *p, int wait_time); /* the poller itself */
|
REGPRM2 void (*poll)(struct poller *p, int wait_time); /* the poller itself */
|
||||||
|
@ -47,22 +47,24 @@ static int epoll_fd;
|
|||||||
* instead of the usual macros improve the FD_* performance by about 80%,
|
* instead of the usual macros improve the FD_* performance by about 80%,
|
||||||
* and that marking them regparm(2) adds another 20%.
|
* and that marking them regparm(2) adds another 20%.
|
||||||
*/
|
*/
|
||||||
REGPRM2 static int __fd_isset(const int fd, const int dir)
|
REGPRM2 static int __fd_isset(const int fd, int dir)
|
||||||
{
|
{
|
||||||
return FD_ISSET(fd, fd_evts[dir]);
|
return FD_ISSET(fd, fd_evts[dir]);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static void __fd_set(const int fd, const int dir)
|
REGPRM2 static int __fd_set(const int fd, int dir)
|
||||||
{
|
{
|
||||||
FD_SET(fd, fd_evts[dir]);
|
FD_SET(fd, fd_evts[dir]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static void __fd_clr(const int fd, const int dir)
|
REGPRM2 static int __fd_clr(const int fd, int dir)
|
||||||
{
|
{
|
||||||
FD_CLR(fd, fd_evts[dir]);
|
FD_CLR(fd, fd_evts[dir]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
REGPRM2 static int __fd_cond_s(const int fd, int dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = !FD_ISSET(fd, fd_evts[dir]);
|
ret = !FD_ISSET(fd, fd_evts[dir]);
|
||||||
@ -71,7 +73,7 @@ REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static int __fd_cond_c(const int fd, const int dir)
|
REGPRM2 static int __fd_cond_c(const int fd, int dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = FD_ISSET(fd, fd_evts[dir]);
|
ret = FD_ISSET(fd, fd_evts[dir]);
|
||||||
|
@ -37,22 +37,24 @@ static struct pollfd *poll_events = NULL;
|
|||||||
* instead of the usual macros improve the FD_* performance by about 80%,
|
* instead of the usual macros improve the FD_* performance by about 80%,
|
||||||
* and that marking them regparm(2) adds another 20%.
|
* and that marking them regparm(2) adds another 20%.
|
||||||
*/
|
*/
|
||||||
REGPRM2 static int __fd_isset(const int fd, const int dir)
|
REGPRM2 static int __fd_isset(const int fd, int dir)
|
||||||
{
|
{
|
||||||
return FD_ISSET(fd, fd_evts[dir]);
|
return FD_ISSET(fd, fd_evts[dir]);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static void __fd_set(const int fd, const int dir)
|
REGPRM2 static int __fd_set(const int fd, int dir)
|
||||||
{
|
{
|
||||||
FD_SET(fd, fd_evts[dir]);
|
FD_SET(fd, fd_evts[dir]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static void __fd_clr(const int fd, const int dir)
|
REGPRM2 static int __fd_clr(const int fd, int dir)
|
||||||
{
|
{
|
||||||
FD_CLR(fd, fd_evts[dir]);
|
FD_CLR(fd, fd_evts[dir]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
REGPRM2 static int __fd_cond_s(const int fd, int dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = !FD_ISSET(fd, fd_evts[dir]);
|
ret = !FD_ISSET(fd, fd_evts[dir]);
|
||||||
@ -61,7 +63,7 @@ REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static int __fd_cond_c(const int fd, const int dir)
|
REGPRM2 static int __fd_cond_c(const int fd, int dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = FD_ISSET(fd, fd_evts[dir]);
|
ret = FD_ISSET(fd, fd_evts[dir]);
|
||||||
|
@ -35,22 +35,24 @@ static fd_set *tmp_evts[2];
|
|||||||
* instead of the usual macros improve the FD_* performance by about 80%,
|
* instead of the usual macros improve the FD_* performance by about 80%,
|
||||||
* and that marking them regparm(2) adds another 20%.
|
* and that marking them regparm(2) adds another 20%.
|
||||||
*/
|
*/
|
||||||
REGPRM2 static int __fd_isset(const int fd, const int dir)
|
REGPRM2 static int __fd_isset(const int fd, int dir)
|
||||||
{
|
{
|
||||||
return FD_ISSET(fd, fd_evts[dir]);
|
return FD_ISSET(fd, fd_evts[dir]);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static void __fd_set(const int fd, const int dir)
|
REGPRM2 static int __fd_set(const int fd, int dir)
|
||||||
{
|
{
|
||||||
FD_SET(fd, fd_evts[dir]);
|
FD_SET(fd, fd_evts[dir]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static void __fd_clr(const int fd, const int dir)
|
REGPRM2 static int __fd_clr(const int fd, int dir)
|
||||||
{
|
{
|
||||||
FD_CLR(fd, fd_evts[dir]);
|
FD_CLR(fd, fd_evts[dir]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
REGPRM2 static int __fd_cond_s(const int fd, int dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = !FD_ISSET(fd, fd_evts[dir]);
|
ret = !FD_ISSET(fd, fd_evts[dir]);
|
||||||
@ -59,7 +61,7 @@ REGPRM2 static int __fd_cond_s(const int fd, const int dir)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static int __fd_cond_c(const int fd, const int dir)
|
REGPRM2 static int __fd_cond_c(const int fd, int dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = FD_ISSET(fd, fd_evts[dir]);
|
ret = FD_ISSET(fd, fd_evts[dir]);
|
||||||
@ -68,7 +70,7 @@ REGPRM2 static int __fd_cond_c(const int fd, const int dir)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM1 static void __fd_rem(const int fd)
|
REGPRM1 static void __fd_rem(int fd)
|
||||||
{
|
{
|
||||||
FD_CLR(fd, fd_evts[DIR_RD]);
|
FD_CLR(fd, fd_evts[DIR_RD]);
|
||||||
FD_CLR(fd, fd_evts[DIR_WR]);
|
FD_CLR(fd, fd_evts[DIR_WR]);
|
||||||
|
Loading…
Reference in New Issue
Block a user