mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 13:21:29 +02:00
[BUG] O(1) pollers should check their FD before closing it
epoll, sepoll and kqueue pollers should check that their fd is not closed before attempting to close it, otherwise we can end up with multiple closes of fd #0 upon exit, which is harmless but dirty.
This commit is contained in:
parent
01b3a53f49
commit
d79e79b436
@ -312,7 +312,7 @@ REGPRM1 static int _do_init(struct poller *p)
|
||||
free(epoll_events);
|
||||
fail_ee:
|
||||
close(epoll_fd);
|
||||
epoll_fd = 0;
|
||||
epoll_fd = -1;
|
||||
fail_fd:
|
||||
p->pref = 0;
|
||||
return 0;
|
||||
@ -331,8 +331,10 @@ REGPRM1 static void _do_term(struct poller *p)
|
||||
free(fd_evts);
|
||||
free(epoll_events);
|
||||
|
||||
if (epoll_fd >= 0) {
|
||||
close(epoll_fd);
|
||||
epoll_fd = 0;
|
||||
epoll_fd = -1;
|
||||
}
|
||||
|
||||
chg_ptr = NULL;
|
||||
chg_list = NULL;
|
||||
@ -366,6 +368,7 @@ REGPRM1 static int _do_test(struct poller *p)
|
||||
*/
|
||||
REGPRM1 static int _do_fork(struct poller *p)
|
||||
{
|
||||
if (epoll_fd >= 0)
|
||||
close(epoll_fd);
|
||||
epoll_fd = epoll_create(global.maxsock + 1);
|
||||
if (epoll_fd < 0)
|
||||
@ -385,6 +388,8 @@ static void _do_register(void)
|
||||
|
||||
if (nbpollers >= MAX_POLLERS)
|
||||
return;
|
||||
|
||||
epoll_fd = -1;
|
||||
p = &pollers[nbpollers++];
|
||||
|
||||
p->name = "epoll";
|
||||
|
@ -188,7 +188,7 @@ REGPRM1 static int _do_init(struct poller *p)
|
||||
free(kev);
|
||||
fail_kev:
|
||||
close(kqueue_fd);
|
||||
kqueue_fd = 0;
|
||||
kqueue_fd = -1;
|
||||
fail_fd:
|
||||
p->pref = 0;
|
||||
return 0;
|
||||
@ -203,8 +203,11 @@ REGPRM1 static void _do_term(struct poller *p)
|
||||
free(fd_evts[DIR_WR]);
|
||||
free(fd_evts[DIR_RD]);
|
||||
free(kev);
|
||||
|
||||
if (kqueue_fd >= 0) {
|
||||
close(kqueue_fd);
|
||||
kqueue_fd = 0;
|
||||
kqueue_fd = -1;
|
||||
}
|
||||
|
||||
p->private = NULL;
|
||||
p->pref = 0;
|
||||
@ -232,6 +235,7 @@ REGPRM1 static int _do_test(struct poller *p)
|
||||
*/
|
||||
REGPRM1 static int _do_fork(struct poller *p)
|
||||
{
|
||||
if (kqueue_fd >= 0)
|
||||
close(kqueue_fd);
|
||||
kqueue_fd = kqueue();
|
||||
if (kqueue_fd < 0)
|
||||
@ -251,6 +255,8 @@ static void _do_register(void)
|
||||
|
||||
if (nbpollers >= MAX_POLLERS)
|
||||
return;
|
||||
|
||||
kqueue_fd = -1;
|
||||
p = &pollers[nbpollers++];
|
||||
|
||||
p->name = "kqueue";
|
||||
|
@ -591,7 +591,7 @@ REGPRM1 static int _do_init(struct poller *p)
|
||||
free(epoll_events);
|
||||
fail_ee:
|
||||
close(epoll_fd);
|
||||
epoll_fd = 0;
|
||||
epoll_fd = -1;
|
||||
fail_fd:
|
||||
p->pref = 0;
|
||||
return 0;
|
||||
@ -607,8 +607,10 @@ REGPRM1 static void _do_term(struct poller *p)
|
||||
free(spec_list);
|
||||
free(epoll_events);
|
||||
|
||||
if (epoll_fd >= 0) {
|
||||
close(epoll_fd);
|
||||
epoll_fd = 0;
|
||||
epoll_fd = -1;
|
||||
}
|
||||
|
||||
fd_list = NULL;
|
||||
spec_list = NULL;
|
||||
@ -641,6 +643,7 @@ REGPRM1 static int _do_test(struct poller *p)
|
||||
*/
|
||||
REGPRM1 static int _do_fork(struct poller *p)
|
||||
{
|
||||
if (epoll_fd >= 0)
|
||||
close(epoll_fd);
|
||||
epoll_fd = epoll_create(global.maxsock + 1);
|
||||
if (epoll_fd < 0)
|
||||
@ -660,6 +663,8 @@ static void _do_register(void)
|
||||
|
||||
if (nbpollers >= MAX_POLLERS)
|
||||
return;
|
||||
|
||||
epoll_fd = -1;
|
||||
p = &pollers[nbpollers++];
|
||||
|
||||
p->name = "sepoll";
|
||||
|
Loading…
x
Reference in New Issue
Block a user