]> granicus.if.org Git - libevent/commitdiff
add a signal and free the base for reinit test
authorNiels Provos <provos@gmail.com>
Sun, 20 Jul 2008 23:31:28 +0000 (23:31 +0000)
committerNiels Provos <provos@gmail.com>
Sun, 20 Jul 2008 23:31:28 +0000 (23:31 +0000)
svn:r915

test/regress.c

index 1fd7c30a0396109abb671e7454936d702e2f6196..f1539f66fb01454eeba7936142ff18db374d9b19 100644 (file)
@@ -479,12 +479,14 @@ test_periodictimeout(void)
 }
 
 #ifndef WIN32
+static void signal_cb(int fd, short event, void *arg);
+
 extern struct event_base *current_base;
 static void
 test_fork(void)
 {
        int status;
-       struct event ev;
+       struct event ev, sig_ev;
        pid_t pid;
 
        setup_test("After fork: ");
@@ -495,6 +497,9 @@ test_fork(void)
        if (event_add(&ev, NULL) == -1)
                exit(1);
 
+       signal_set(&sig_ev, SIGALRM, signal_cb, &ev);
+       signal_add(&sig_ev, NULL);
+
        if ((pid = fork()) == 0) {
                /* in the child */
                if (event_reinit(current_base) == -1) {
@@ -502,10 +507,14 @@ test_fork(void)
                        exit(1);
                }
 
+               signal_del(&sig_ev);
+
                called = 0;
 
                event_dispatch();
 
+               event_base_free(current_base);
+
                /* we do not send an EOF; simple_read_cb requires an EOF 
                 * to set test_ok.  we just verify that the callback was
                 * called. */
@@ -515,6 +524,8 @@ 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) {