mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 04:50:37 -04:00
Fix memory-leak of signal handler array with kqueue.
It turns out that kqueue_dealloc wasn't calling evsig_dealloc() (because it doesn't use the main signal handler logic) so the sh_old array was leaking. This patch also introduces a fix in evsig_dealloc() where we set the sh_old array to NULL when we free it, so that main/fork can pass.
This commit is contained in:
parent
07e9e9b4b1
commit
e1ffbb82e3
1
kqueue.c
1
kqueue.c
@ -404,6 +404,7 @@ static void
|
|||||||
kq_dealloc(struct event_base *base)
|
kq_dealloc(struct event_base *base)
|
||||||
{
|
{
|
||||||
struct kqop *kqop = base->evbase;
|
struct kqop *kqop = base->evbase;
|
||||||
|
evsig_dealloc(base);
|
||||||
kqop_free(kqop);
|
kqop_free(kqop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
signal.c
16
signal.c
@ -334,13 +334,19 @@ evsig_dealloc(struct event_base *base)
|
|||||||
_evsig_restore_handler(base, i);
|
_evsig_restore_handler(base, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]);
|
if (base->sig.ev_signal_pair[0] != -1) {
|
||||||
base->sig.ev_signal_pair[0] = -1;
|
EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]);
|
||||||
EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]);
|
base->sig.ev_signal_pair[0] = -1;
|
||||||
base->sig.ev_signal_pair[1] = -1;
|
}
|
||||||
|
if (base->sig.ev_signal_pair[1] != -1) {
|
||||||
|
EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]);
|
||||||
|
base->sig.ev_signal_pair[1] = -1;
|
||||||
|
}
|
||||||
base->sig.sh_old_max = 0;
|
base->sig.sh_old_max = 0;
|
||||||
|
|
||||||
/* per index frees are handled in evsig_del() */
|
/* per index frees are handled in evsig_del() */
|
||||||
if (base->sig.sh_old)
|
if (base->sig.sh_old) {
|
||||||
mm_free(base->sig.sh_old);
|
mm_free(base->sig.sh_old);
|
||||||
|
base->sig.sh_old = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user