chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.72k stars 1.19k forks source link

Using io_service and steady_timer from different .so libraries - is it supported? #733

Open ghost opened 3 years ago

ghost commented 3 years ago

@Kh-Oleg commented on Nov 22, 2019, 8:07 AM UTC:

I use some 3rd party library, which consists of the library itself, let's say libmain.so and an optional plugin, libplugin.so, loaded at runtime. Both of them use asio.

libmain.so creates, owns and runs io_service instance and passes a reference to the plugin to initialize the timer.

Problem: when io_service and timer are created in different .so modules, the timer is not triggered. When they are created in the same module - everything works.

I did some investigation and it seems that the problem in boost::asio::detail::service_registry. It uses address of a static filed 'id' to identify a type and to check for duplicates in the registry. Addresses from different .so are different, so io_service listens (via select) for a wrong instance of internal timer service.

My question: usage of io_service and timers from different .so modules - is it a supported use case? Platform: QNX Neutrino, boost asio: v. 1.61

This issue was moved by chriskohlhoff from boostorg/asio#303.

daexel commented 2 years ago

Hey ghost did you already solved the issue? I still struggle with the timers for qnx and the service discovery. :cry: