Comment 0 for bug 1441339

Revision history for this message
Nischal Sheth (nsheth) wrote :

According to boost asio documentation, accessing a given instance of
a socket object from different threads is unsafe. The implementation
of the TcpSession class does not conform to this requirement.

- Async read for the socket is started from the io::Reader Task
- Handler for the async read is executed in the context of main thread
- Writes to the socket are done from the bgp::Send Task
- Handler for write ready callback is executed in the context of main thread

Since there's no way to enforce mutual exclusion between Tasks and
the main thread, this clearly is a problem. It results in situations where
a sender application has sent data, but the receiver application doesn't
get it. The data is in the kernel socket buffers at the sender, but the
asio library never reads the data.

Proposed fix is to do everything in the context of the main thread by
posting handlers.