[ASIO] Having a hard time after upgrading my boost libraries
Folks, I recently moved to boost 1.52, been using a pretty old version of boost earlier. Quite a number of pieces of my code have stopped working since then, but the one that's really a pain is the ASIO piece. I have a lot of code that makes use of ASIO's async read/write and other calls and there seems to be a problem reading data from socket with async_read_until - sometimes I get empty string, there's valid data at other times. My code is heavily multi-threaded. This problem doesn't show up in single threaded environment at all. My OS is SUSE 11 and g++-4.3.3 as the compiler. I may have to post some code eventually but on the top off your head - do you have any pointers for me? Thanks for your time. Arpan
2013/5/19 Arpan Sen
Folks,
I recently moved to boost 1.52, been using a pretty old version of boost earlier. Quite a number of pieces of my code have stopped working since then, but the one that's really a pain is the ASIO piece. I have a lot of code that makes use of ASIO's async read/write and other calls and there seems to be a problem reading data from socket with async_read_until - sometimes I get empty string, there's valid data at other times.
My code is heavily multi-threaded. This problem doesn't show up in single threaded environment at all. My OS is SUSE 11 and g++-4.3.3 as the compiler. I may have to post some code eventually but on the top off your head - do you have any pointers for me?
I have no solution, but following thoughts popped up in my head: Maybe some error occur during read/write. Do you check const boost::system::error_code& error in all handlers? Are buffers modified from only a single thread at a moment of time (each handler has its own buffer?)? Does OS limits allow you to create required amount of threads/sockets? -- Best regards, Antony Polukhin
On 19/05/2013 14.54, Arpan Sen wrote:
Folks,
I recently moved to boost 1.52, been using a pretty old version of boost earlier. Quite a number of pieces of my code have stopped working since then, but the one that's really a pain is the ASIO piece. I have a lot of code that makes use of ASIO's async read/write and other calls and there seems to be a problem reading data from socket with async_read_until - sometimes I get empty string, there's valid data at other times.
My code is heavily multi-threaded. This problem doesn't show up in single threaded environment at all. My OS is SUSE 11 and g++-4.3.3 as the compiler. I may have to post some code eventually but on the top off your head - do you have any pointers for me?
Consider that the buffer you are passing to your async calls has to survive the handler. How many threads are running the io_service::run ? Consider that boost::asio::sockets are not multithread so only one thread at time can call the async calls on it. Can the handlers running concurrently ? If not you have to use the strand. Regards Gaetano Mendola
participants (3)
-
Antony Polukhin
-
Arpan Sen
-
Gaetano Mendola