[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Re: libevent 2.1.11-stable breaks the links browser
On Tue, 3 Sep 2019, Azat Khuzhin wrote:
> > OK, so I will just add a code that blacklists version 2.1.11 and assume
> > that all the following versions will be ok.
I did some more testing and it turns out that libevent 1.4.15-stable
shipped with OpenBSD 6.4 using the kqueue backend also doesn't handle
event_reinit from callback. event_reinit succeeds, but it reports a bad
file descriptor error when we return to the event loop.
So I modified the links browser to call event_reinit out of the callbacks
- that works on OpenBSD.
> FYI: upstream commit is ddacaef59ab6808a0801007d0a681f2415af4871
>
> > BTW - I'd like to ask - is it OK to call event_base_free from the libevent
> > callback after fork? (assuming that we never return back to the callback)
> >
> > I want to avoid leaking file descriptors to external programs started by
> > links
>
> Hm, what about O_CLOEXEC?
You are right - libevent uses O_CLOEXEC, so the file descriptor doesn't
leak into subprocesses.
> > - so in the forked child I call event_reinit(base) and
> > event_base_free(base) just to clean the open file descriptors. Is it OK or
> > is it unsupported?
>
> Hm, AFAIR you have analog of daemon(3), so in this case parent is gone
> and child process doing all the job, then why do you call
> event_base_free() just after event_reinit(), what did I miss?
>
> But anyway you cannot call event_base_free() from the loop, but if you
> call _exit() just after event_base_free(), than who cares?
>
> --
> Azat.
There are two uses for fork() in the links browser - one is to "daemonize"
itself when the user closes the master session and there are other
sessions attached to the AF_UNIX socket.
Another use of fork() is for dns lookups and spawning external viewers.
For the first use, event_reinit is needed (but the daemonizing could be
deferred until we are out of the event callbacks).
For the second use, it never returns back to the event loop. I used
event_reinit(), event_base_free() in the child just after fork() - but it
is not really required, so I deleted it.
Mikulas
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.