Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a boost::asio::io_service object between dynamically loaded libraries

First what I did (minimum sample will be provided if it's not just me doing something plain stupid):

I have a GUI application that shall support several network interfaces to change content that's displayed in the GUI. The network interfaces are realized as plugins that are dynamically loaded on GUI startup. The GUI application provides a boost::asio::io_service object that it passes via reference to the interfaces so they can use that to build the asynchronous I/O. In the GUI thread this io_service object is than polled to synchronise the network interfaces' access to the content.

The problem now is that the handlers don't get called by the io_service object when it is polled. To narrow this down I implemented only one interface and created the io_service object therein, still calling the poll from the GUI thread and that works.

My question now is: is it possible that there is a general problem with passing the io_service object into DLL functions loaded at runtime?

If the scenario is too unclear, I'll provide a minimum example.

EDIT: I feel really stupid :) Just hacked together a minimum example and that - of course - works like a charm. That pretty much means the problem origins from some other part of the software.

So thanks everyone for their input!

To make this question at least a little bit useful: Anyone who wants to do something similar (plugins for network synchronized via boost::asio::io_service), you can download the minimum example here.

like image 585
LiMuBei Avatar asked Jan 26 '11 10:01

LiMuBei


1 Answers

I would check several options:
* Maybe the object is copied at some point rather than passed by reference; you can make it boost::noncopyable to prevent this from happening.
* Check the return value of poll if it is bigger than 0 some handler was run; if it is 0 the problem is boost think there are no handler.
* Add a test handler in your GUI app to rule out the option it is DLL-related problem.

Happy debugging!

like image 193
Uri Cohen Avatar answered Oct 26 '22 01:10

Uri Cohen