mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 03:44:22 -04:00
test/regress: main/fork: rewrite assertions by just removing event in callback
Instead of assigning some variable value (got_child), and schedule exit from loop from that callback, just remove event for that signal, and event loop will exit automatically when there will be no events.
This commit is contained in:
parent
88640aa1ca
commit
088d8b39f9
@ -817,28 +817,21 @@ end:
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
static void signal_cb(evutil_socket_t fd, short event, void *arg);
|
||||
|
||||
#define current_base event_global_current_base_
|
||||
extern struct event_base *current_base;
|
||||
|
||||
static void
|
||||
child_signal_cb(evutil_socket_t fd, short event, void *arg)
|
||||
fork_signal_cb(evutil_socket_t fd, short events, void *arg)
|
||||
{
|
||||
struct timeval tv;
|
||||
int *pint = arg;
|
||||
|
||||
*pint = 1;
|
||||
|
||||
tv.tv_usec = 500000;
|
||||
tv.tv_sec = 0;
|
||||
event_loopexit(&tv);
|
||||
event_del(arg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_fork(void)
|
||||
{
|
||||
int status, got_sigchld = 0;
|
||||
int status;
|
||||
struct event ev, sig_ev;
|
||||
pid_t pid;
|
||||
|
||||
@ -855,7 +848,7 @@ test_fork(void)
|
||||
if (event_add(&ev, NULL) == -1)
|
||||
exit(1);
|
||||
|
||||
evsignal_set(&sig_ev, SIGCHLD, child_signal_cb, &got_sigchld);
|
||||
evsignal_set(&sig_ev, SIGCHLD, fork_signal_cb, &sig_ev);
|
||||
evsignal_add(&sig_ev, NULL);
|
||||
|
||||
event_base_assert_ok_(current_base);
|
||||
@ -917,11 +910,6 @@ test_fork(void)
|
||||
|
||||
event_dispatch();
|
||||
|
||||
if (!got_sigchld) {
|
||||
fprintf(stdout, "FAILED (sigchld)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
evsignal_del(&sig_ev);
|
||||
|
||||
end:
|
||||
|
Loading…
x
Reference in New Issue
Block a user