Concurrency issue in TcpSession implementation
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Juniper Openstack | Status tracked in Trunk | |||||
R1.1 |
Fix Committed
|
High
|
Nischal Sheth | |||
R2.0 |
Fix Committed
|
High
|
Nischal Sheth | |||
R2.1 |
Fix Committed
|
High
|
Nischal Sheth | |||
Trunk |
Fix Committed
|
High
|
Nischal Sheth |
Bug Description
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 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 kernel socket buffers at the receiver,
but the asio library never reads the data.
Proposed fix is to do everything in the context of the main thread by
posting handlers.
Review in progress for https:/ /review. opencontrail. org/9001
Submitter: Nischal Sheth (<email address hidden>)