[CDRIVER-2903] Coverity analysis defect 103554: Waiting while holding a lock Created: 20/Dec/18  Updated: 17/Jul/23  Resolved: 17/Jul/23

Status: Closed
Project: C Driver
Component/s: tests
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Trivial - P5
Reporter: Coverity Collector User Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: CDRIVER-4575

 Description   

A lock is held while waiting for a long running or blocking operation to complete

Defect 103554 (STATIC_C)
Checker SLEEP (subcategory none)
File: /src/libmongoc/tests/mock_server/mock-server.c
Function main_thread
/src/libmongoc/tests/mock_server/mock-server.c, line: 1577
Calling function "pthread_mutex_lock" acquires lock "server->mutex".

             bson_mutex_lock (&server->mutex);



 Comments   
Comment by Kevin Albertson [ 17/Jul/23 ]

At present, the blocking operation done while holding a lock appears to be establishing a TLS stream:

bson_mutex_lock (&server->mutex);
if (server->ssl) {
   mongoc_stream_t *tls_stream;
   server->ssl_opts.weak_cert_validation = 1;
   tls_stream = mongoc_stream_tls_new_with_hostname (
      client_stream, NULL, &server->ssl_opts, 0);
   if (!tls_stream) {
      mongoc_stream_destroy (client_stream);
      bson_mutex_unlock (&server->mutex);
      perror ("Failed to attach tls stream");
      break;
   }
   client_stream = tls_stream;
}
bson_mutex_unlock (&server->mutex);

I expect this has neglible impact on tests. I expect there is no current use case for the mock server handling a high volume of concurrent TLS connections quickly.

Closing as "Won't Fix".

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