[CDRIVER-3752] Missing call to bson_mutex_unlock in _mongoc_client_pool_set_internal_tls_opts Created: 16/Jul/20  Updated: 28/Oct/23  Resolved: 16/Jul/20

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.17.0-beta
Fix Version/s: 1.18.0, 1.18.0-alpha

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

A call to bson_mutex_unlock was omitted in this commit: https://github.com/mongodb/mongo-c-driver/commit/7f785ffedb679b1fb5c62ae0369dec218980a016#diff-2a89b54dc123a4ba94a2a069c6aa70e6R85 when adding support for new TLS options for OCSP.



 Comments   
Comment by Githook User [ 16/Jul/20 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-3752 add missing bson_mutex_unlock
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/13d4e77b0bc78b332c4805254afcd4330bed9d3d

Comment by Kevin Albertson [ 16/Jul/20 ]

PR: https://github.com/mongodb/mongo-c-driver/pull/664

Comment by Kevin Albertson [ 16/Jul/20 ]

Upon further inspection, I don't think this is currently reproducible based on how _mongoc_client_pool_set_internal_tls_opts is called.

The only caller of _mongoc_client_pool_set_internal_tls_opts is this snippet:

if (mongoc_uri_get_tls (pool->uri)) {
      mongoc_ssl_opt_t ssl_opt = {0};
      _mongoc_internal_tls_opts_t internal_tls_opts = {0};
 
      _mongoc_ssl_opts_from_uri (&ssl_opt, &internal_tls_opts, pool->uri);
      /* sets use_ssl = true */
      mongoc_client_pool_set_ssl_opts (pool, &ssl_opt);
      _mongoc_client_pool_set_internal_tls_opts (pool, &internal_tls_opts);
   }

The first call to mongoc_client_pool_set_ssl_opts is necessarily called with a non-NULL ssl_opt, and that will set the pool->ssl_opts_set = true. The deadlock in question cannot occur because the check will always be false.

Regardless, it would be an improvement to unlock before returning to prevent the possibility of a future deadlock.

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