Subject: [Boost-bugs] [Boost C++ Libraries] #4162: io_service can't be used correctly after fork().
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-04-28 20:44:39
#4162: io_service can't be used correctly after fork().
----------------------------------+-----------------------------------------
Reporter: artyomtnk@⦠| Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: asio
Version: Boost 1.42.0 | Severity: Problem
Keywords: asio posix fork unix |
----------------------------------+-----------------------------------------
Hello,
I'm trying to run standard "prefork" unix configuration with
boost-asio.
I have following setup:
1. I bind to some port.
2. I prefork several processes.
3. As new connection is avalible one of processes accept it
and run the main loop.
---------------------
Issue:
The io_service is created at the begging and creates
eventfd (or pipe), and unlike devpoll, kqueue or epoll it is
shared between forked processes.
---------------------
There is the problem:
When one thread in process try to "post" something to event
loop it interrupts the select with evenfd... And accidentially
other process may actually receive this notification and wake up
when the main process that should receive notification does not.
---------------------
In short
If io_service was created before fork(), post() member function
would not work correctly.
---------------------
Solutions:
1) Postpone creation of pipe/eventfd to the stage when run()
is called instead of construction of io_service.
2) Reopen interrupter if fork() was called.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4162> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC