[CXX-905] Strange results of DBClientConnection::isStillConnected() Created: 05/May/16  Updated: 09/May/16  Resolved: 09/May/16

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: legacy-1.1.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andrey Kolkov Assignee: Andrew Morrow (Inactive)
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CXX-906 Null dereference in DBClientWithComma... Closed

 Description   

Before connection called it returns true. It's a normal behaviour?
Maybe, I found trouble code at sources:
https://github.com/mongodb/mongo-cxx-driver/blob/legacy/src/mongo/client/dbclientinterface.h#L1802



 Comments   
Comment by Andrew Morrow (Inactive) [ 09/May/16 ]

I'm closing this ticket because I've not heard back from you. Please feel free to re-open the ticket if there is anything else we can help with.

Comment by Andrew Morrow (Inactive) [ 05/May/16 ]

androndo - I looked into this. This code was first introduced in the MongoDB server repository here:

https://github.com/mongodb/mongo/commit/61b8f72884dc6fee89b91a30021f41e50cb9de0e

That was before we split the C++ driver out of the MongoDB sources, and, as far as I can tell, that line has never changed since it was first written, in either body of code. I will try to do some research into why it works that way, however it was a long time ago. Also, please note that this sort of function is inherently racy: even though this function returns 'true', the connection could still go bad between when your program reads the result of calling isStillConnected, and when you actually try to use the connection. So, I can't recommend relying on this as a way of trying to be aware of connection state to work around other issues. Regarding the other issue you filed, I'll reply in that ticket.

Generated at Wed Feb 07 22:00:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.