[CSHARP-1690] Race condition could result in BinaryConnection Dispose method running twice Created: 13/Jun/16  Updated: 23/Sep/16  Resolved: 15/Jun/16

Status: Closed
Project: C# Driver
Component/s: Connectivity
Affects Version/s: 2.2.4
Fix Version/s: 2.3

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The Dispose method of BinaryConnection has code to prevent it from being executed twice. See:

https://github.com/mongodb/mongo-csharp-driver/blob/ebc40a80278f79ab86ce19eb6b5656044ee56c65/src/MongoDB.Driver.Core/Core/Connections/BinaryConnection.cs#L172

But if one thread calls Dispose while another thread is in the middle of opening the connection a race condition exists where the _state of the connection can be changed away from Disposed allowing the body of the Dispose method to subsequently be executed a second time.



 Comments   
Comment by Githook User [ 15/Jun/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1690: Fix race condition with BinaryConnection Dispose.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6508d75b74b844892ba3f22f9bb2877db2b96dc7

Generated at Wed Feb 07 21:40:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.