mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-15 15:25:09 -04:00
add a signal and free the base for reinit test
svn:r915
This commit is contained in:
parent
1c164cebb8
commit
a4e2f52a44
@ -479,12 +479,14 @@ test_periodictimeout(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
static void signal_cb(int fd, short event, void *arg);
|
||||||
|
|
||||||
extern struct event_base *current_base;
|
extern struct event_base *current_base;
|
||||||
static void
|
static void
|
||||||
test_fork(void)
|
test_fork(void)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
struct event ev;
|
struct event ev, sig_ev;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
setup_test("After fork: ");
|
setup_test("After fork: ");
|
||||||
@ -495,6 +497,9 @@ test_fork(void)
|
|||||||
if (event_add(&ev, NULL) == -1)
|
if (event_add(&ev, NULL) == -1)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
signal_set(&sig_ev, SIGALRM, signal_cb, &ev);
|
||||||
|
signal_add(&sig_ev, NULL);
|
||||||
|
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
/* in the child */
|
/* in the child */
|
||||||
if (event_reinit(current_base) == -1) {
|
if (event_reinit(current_base) == -1) {
|
||||||
@ -502,10 +507,14 @@ test_fork(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signal_del(&sig_ev);
|
||||||
|
|
||||||
called = 0;
|
called = 0;
|
||||||
|
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
|
event_base_free(current_base);
|
||||||
|
|
||||||
/* we do not send an EOF; simple_read_cb requires an EOF
|
/* we do not send an EOF; simple_read_cb requires an EOF
|
||||||
* to set test_ok. we just verify that the callback was
|
* to set test_ok. we just verify that the callback was
|
||||||
* called. */
|
* called. */
|
||||||
@ -515,6 +524,8 @@ test_fork(void)
|
|||||||
/* wait for the child to read the data */
|
/* wait for the child to read the data */
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
|
signal_del(&sig_ev);
|
||||||
|
|
||||||
write(pair[0], TEST1, strlen(TEST1)+1);
|
write(pair[0], TEST1, strlen(TEST1)+1);
|
||||||
|
|
||||||
if (waitpid(pid, &status, 0) == -1) {
|
if (waitpid(pid, &status, 0) == -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user