Under FreeBSD I was not able to start mogstored if the daemonize option was
specified: it terminated unexpectedly.
It turned up that the issue was related to kqueue initialization in
Danga::Socket.
Danga::Socket does poller initialization only once (see _InitPoller), on the
first usage.
In mogstored we have the following sequence:
{{{
$httpsrv->start # Danga::Socket (and kqueue) is initialized here
Perlbal::daemonize() # fork(2)
...
Mogstored::SideChannelListener # kqueue is used again by Danga::Socket
}}}
The issue is that the kernel event queue is not inherited by a child created
with fork(2). See e.g. kqueue(2) manual page:
http://www.freebsd.org/cgi/man.cgi?query=kqueue&apropos=0&sektion=0&manpath=Free
BSD+9.0-RELEASE&arch=default&format=html
So when in SideChannelListener kevent is called by Danga::Socket using the
inhereted kqueue descriptor, "bad file descriptor" error is generated (which
can be checked with ktrace).
The attached patch, which moves $httpsrv->start after daemonize(), fixes the
issue for me.
Original issue reported on code.google.com by to.my.trociny@gmail.com on 16 Sep 2012 at 7:24
Original issue reported on code.google.com by
to.my.trociny@gmail.com
on 16 Sep 2012 at 7:24Attachments: