mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
[CLEANUP] sepoll: clean up the fd_clr/fd_set functions
This cleanup also slightly reduces code size due to a better construct and the use of an inlined version of alloc_spec_entry().
This commit is contained in:
parent
7859991dd7
commit
ff9d5ba721
@ -173,9 +173,10 @@ static int epoll_fd;
|
|||||||
static struct epoll_event ev;
|
static struct epoll_event ev;
|
||||||
|
|
||||||
|
|
||||||
REGPRM1 static void alloc_spec_entry(const int fd)
|
REGPRM1 static inline void alloc_spec_entry(const int fd)
|
||||||
{
|
{
|
||||||
if (fd_list[fd].s1)
|
if (fd_list[fd].s1)
|
||||||
|
/* sometimes the entry already exists for the other direction */
|
||||||
return;
|
return;
|
||||||
fd_list[fd].s1 = nbspec + 1;
|
fd_list[fd].s1 = nbspec + 1;
|
||||||
spec_list[nbspec] = fd;
|
spec_list[nbspec] = fd;
|
||||||
@ -231,7 +232,6 @@ REGPRM2 static int __fd_is_set(const int fd, int dir)
|
|||||||
*/
|
*/
|
||||||
REGPRM2 static int __fd_set(const int fd, int dir)
|
REGPRM2 static int __fd_set(const int fd, int dir)
|
||||||
{
|
{
|
||||||
__label__ switch_state;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
#if DEBUG_DEV
|
#if DEBUG_DEV
|
||||||
@ -242,25 +242,19 @@ REGPRM2 static int __fd_set(const int fd, int dir)
|
|||||||
#endif
|
#endif
|
||||||
i = ((unsigned)fd_list[fd].e >> dir) & FD_EV_MASK_DIR;
|
i = ((unsigned)fd_list[fd].e >> dir) & FD_EV_MASK_DIR;
|
||||||
|
|
||||||
if (i == FD_EV_IDLE) {
|
if (i != FD_EV_STOP) {
|
||||||
|
if (unlikely(i != FD_EV_IDLE))
|
||||||
|
return 0;
|
||||||
// switch to SPEC state and allocate a SPEC entry.
|
// switch to SPEC state and allocate a SPEC entry.
|
||||||
fd_created++;
|
fd_created++;
|
||||||
alloc_spec_entry(fd);
|
alloc_spec_entry(fd);
|
||||||
switch_state:
|
|
||||||
fd_list[fd].e ^= (unsigned int)(FD_EV_IN_SL << dir);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (i == FD_EV_STOP) {
|
fd_list[fd].e ^= (unsigned int)(FD_EV_IN_SL << dir);
|
||||||
// switch to WAIT state
|
return 1;
|
||||||
goto switch_state;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGPRM2 static int __fd_clr(const int fd, int dir)
|
REGPRM2 static int __fd_clr(const int fd, int dir)
|
||||||
{
|
{
|
||||||
__label__ switch_state;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
#if DEBUG_DEV
|
#if DEBUG_DEV
|
||||||
@ -271,22 +265,18 @@ REGPRM2 static int __fd_clr(const int fd, int dir)
|
|||||||
#endif
|
#endif
|
||||||
i = ((unsigned)fd_list[fd].e >> dir) & FD_EV_MASK_DIR;
|
i = ((unsigned)fd_list[fd].e >> dir) & FD_EV_MASK_DIR;
|
||||||
|
|
||||||
if (i == FD_EV_SPEC) {
|
if (i != FD_EV_SPEC) {
|
||||||
// switch to IDLE state
|
if (unlikely(i != FD_EV_WAIT))
|
||||||
goto switch_state;
|
return 0;
|
||||||
}
|
|
||||||
else if (likely(i == FD_EV_WAIT)) {
|
|
||||||
// switch to STOP state
|
// switch to STOP state
|
||||||
/* We will create a queue entry for this one because we want to
|
/* We will create a queue entry for this one because we want to
|
||||||
* process it later in order to merge it with other events on
|
* process it later in order to merge it with other events on
|
||||||
* the same FD.
|
* the same FD.
|
||||||
*/
|
*/
|
||||||
alloc_spec_entry(fd);
|
alloc_spec_entry(fd);
|
||||||
switch_state:
|
|
||||||
fd_list[fd].e ^= (unsigned int)(FD_EV_IN_SL << dir);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
fd_list[fd].e ^= (unsigned int)(FD_EV_IN_SL << dir);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* normally unused */
|
/* normally unused */
|
||||||
|
Loading…
Reference in New Issue
Block a user