Ticket #4162 (closed Feature Requests: fixed)
io_service can't be used correctly after fork().
|Reported by:||artyomtnk@…||Owned by:||chris_kohlhoff|
|Milestone:||To Be Determined||Component:||asio|
|Keywords:||asio posix fork unix||Cc:|
I'm trying to run standard "prefork" unix configuration with boost-asio.
I have following setup:
- I bind to some port.
- I prefork several processes.
- As new connection is avalible one of processes accept it
and run the main loop.
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.
If io_service was created before fork(), post() member function would not work correctly.
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.
- Type changed from Bugs to Feature Requests
- Milestone changed from Boost 1.43.0 to To Be Determined