mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MEDIUM: poller: program the update in fd_update_events() for a migrated FD
When an FD is migrated, all pollers program an update. That's useless code duplication, and when thread groups will be supported, this will require an extra round of locking just to verify the update_mask on return. Let's just program the update direction from fd_update_events() as it already does for closed FDs, this becomes more logical.
This commit is contained in:
parent
1b927eb3c3
commit
b1093c6ba2
@ -214,7 +214,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
||||
|
||||
for (count = 0; count < status; count++) {
|
||||
unsigned int n, e;
|
||||
int ret;
|
||||
|
||||
e = epoll_events[count].events;
|
||||
fd = epoll_events[count].data.fd;
|
||||
@ -231,13 +230,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
||||
((e & EPOLLHUP) ? FD_EV_SHUT_RW : 0) |
|
||||
((e & EPOLLERR) ? FD_EV_ERR_RW : 0);
|
||||
|
||||
ret = fd_update_events(fd, n);
|
||||
|
||||
if (ret == FD_UPDT_MIGRATED) {
|
||||
/* FD has been migrated */
|
||||
if (!HA_ATOMIC_BTS(&fdtab[fd].update_mask, tid))
|
||||
fd_updt[fd_nbupdt++] = fd;
|
||||
}
|
||||
fd_update_events(fd, n);
|
||||
}
|
||||
/* the caller will take care of cached events */
|
||||
}
|
||||
|
@ -244,12 +244,9 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
||||
*/
|
||||
ret = fd_update_events(fd, n);
|
||||
|
||||
/* disable polling on this instance if the FD was migrated */
|
||||
if (ret == FD_UPDT_MIGRATED) {
|
||||
if (!HA_ATOMIC_BTS(&fdtab[fd].update_mask, tid))
|
||||
fd_updt[fd_nbupdt++] = fd;
|
||||
/* polling will be on this instance if the FD was migrated */
|
||||
if (ret == FD_UPDT_MIGRATED)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* This file descriptor was closed during the processing of
|
||||
|
@ -178,7 +178,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
||||
|
||||
for (count = 0; count < status; count++) {
|
||||
unsigned int n = 0;
|
||||
int ret;
|
||||
|
||||
fd = kev[count].ident;
|
||||
|
||||
@ -197,13 +196,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
||||
n |= FD_EV_ERR_RW;
|
||||
}
|
||||
|
||||
ret = fd_update_events(fd, n);
|
||||
|
||||
if (ret == FD_UPDT_MIGRATED) {
|
||||
/* FD was migrated, let's stop polling it */
|
||||
if (!HA_ATOMIC_BTS(&fdtab[fd].update_mask, tid))
|
||||
fd_updt[fd_nbupdt++] = fd;
|
||||
}
|
||||
fd_update_events(fd, n);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,8 +213,8 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
||||
|
||||
for (count = 0; status > 0 && count < nbfd; count++) {
|
||||
unsigned int n;
|
||||
int ret;
|
||||
int e = poll_events[count].revents;
|
||||
|
||||
fd = poll_events[count].fd;
|
||||
|
||||
if ((e & POLLRDHUP) && !(cur_poller.flags & HAP_POLL_F_RDHUP))
|
||||
@ -235,13 +235,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
||||
((e & POLLHUP) ? FD_EV_SHUT_RW : 0) |
|
||||
((e & POLLERR) ? FD_EV_ERR_RW : 0);
|
||||
|
||||
ret = fd_update_events(fd, n);
|
||||
|
||||
if (ret == FD_UPDT_MIGRATED) {
|
||||
/* FD was migrated, let's stop polling it */
|
||||
if (!HA_ATOMIC_BTS(&fdtab[fd].update_mask, tid))
|
||||
fd_updt[fd_nbupdt++] = fd;
|
||||
}
|
||||
fd_update_events(fd, n);
|
||||
}
|
||||
}
|
||||
|
||||
|
4
src/fd.c
4
src/fd.c
@ -483,6 +483,10 @@ int fd_update_events(int fd, uint evts)
|
||||
if (!(tmask & tid_bit)) {
|
||||
/* a takeover has started */
|
||||
activity[tid].poll_skip_fd++;
|
||||
|
||||
/* Let the poller know this FD was lost */
|
||||
if (!HA_ATOMIC_BTS(&fdtab[fd].update_mask, tid))
|
||||
fd_updt[fd_nbupdt++] = fd;
|
||||
return FD_UPDT_MIGRATED;
|
||||
}
|
||||
} while (!HA_ATOMIC_CAS(&fdtab[fd].running_mask, &rmask, rmask | tid_bit));
|
||||
|
Loading…
Reference in New Issue
Block a user