Skip to content

Commit

Permalink
Warn if forked from the event loop during event_reinit()
Browse files Browse the repository at this point in the history
Calling fork() from the event loop is not a great idea, since at least
it shares some internal pipes (for handling signals) before
event_reinit() call

Closes: libevent#833
  • Loading branch information
azat committed Jul 1, 2019
1 parent 5388a00 commit 497ef90
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,12 @@ event_reinit(struct event_base *base)

EVBASE_ACQUIRE_LOCK(base, th_base_lock);

if (base->running_loop) {
event_warnx("%s: forked from the event_loop.", __func__);
res = -1;
goto done;
}

evsel = base->evsel;

/* check if this event mechanism requires reinit on the backend */
Expand Down

0 comments on commit 497ef90

Please sign in to comment.