mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
another fix; we also need to remove the signal event from the queue
svn:r918
This commit is contained in:
parent
e67a5ea9bb
commit
3b24f4eedc
5
event.c
5
event.c
@ -375,8 +375,11 @@ event_reinit(struct event_base *base)
|
||||
return (0);
|
||||
|
||||
/* prevent internal delete */
|
||||
if (base->sig.ev_signal_added)
|
||||
if (base->sig.ev_signal_added) {
|
||||
event_queue_remove(base, &base->sig.ev_signal,
|
||||
EVLIST_INSERTED);
|
||||
base->sig.ev_signal_added = 0;
|
||||
}
|
||||
|
||||
if (base->evsel->dealloc != NULL)
|
||||
base->evsel->dealloc(base, base->evbase);
|
||||
|
@ -482,10 +482,24 @@ test_periodictimeout(void)
|
||||
static void signal_cb(int fd, short event, void *arg);
|
||||
|
||||
extern struct event_base *current_base;
|
||||
|
||||
static void
|
||||
child_signal_cb(int fd, short event, void *arg)
|
||||
{
|
||||
struct timeval tv;
|
||||
int *pint = arg;
|
||||
|
||||
*pint = 1;
|
||||
|
||||
tv.tv_usec = 500000;
|
||||
tv.tv_sec = 0;
|
||||
event_loopexit(&tv);
|
||||
}
|
||||
|
||||
static void
|
||||
test_fork(void)
|
||||
{
|
||||
int status;
|
||||
int status, got_sigchld = 0;
|
||||
struct event ev, sig_ev;
|
||||
pid_t pid;
|
||||
|
||||
@ -497,7 +511,7 @@ test_fork(void)
|
||||
if (event_add(&ev, NULL) == -1)
|
||||
exit(1);
|
||||
|
||||
signal_set(&sig_ev, SIGALRM, signal_cb, &ev);
|
||||
signal_set(&sig_ev, SIGCHLD, child_signal_cb, &got_sigchld);
|
||||
signal_add(&sig_ev, NULL);
|
||||
|
||||
if ((pid = fork()) == 0) {
|
||||
@ -524,8 +538,6 @@ test_fork(void)
|
||||
/* wait for the child to read the data */
|
||||
sleep(1);
|
||||
|
||||
signal_del(&sig_ev);
|
||||
|
||||
write(pair[0], TEST1, strlen(TEST1)+1);
|
||||
|
||||
if (waitpid(pid, &status, 0) == -1) {
|
||||
@ -544,6 +556,13 @@ test_fork(void)
|
||||
|
||||
event_dispatch();
|
||||
|
||||
if (!got_sigchld) {
|
||||
fprintf(stdout, "FAILED (sigchld)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
signal_del(&sig_ev);
|
||||
|
||||
cleanup_test();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user