Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDRIVER-938 prohibit calling unsafe client setters with pooled clients #1944

Merged
merged 6 commits into from
Apr 1, 2025

Conversation

kevinAlbs
Copy link
Collaborator

Summary

Update mongoc_client_set_ssl_opts and mongoc_client_set_ssl_stream_initiator to ignore a pooled mongoc_client_t and logs an error.

Motivation

Intended to prevent a user configuring connection options on a pooled client that likely behave unexpectedly:

mongoc_client_t *client = mongoc_client_pool_pop (pool); // Monitoring starts.
mongoc_client_set_ssl_opts (client, opts); // Connections already created for monitoring!
mongoc_client_pool_push (pool, client); // Pushes client back onto pool with different TLS options!

Other mongoc_client_set_* functions are not modified.

Changes to mongoc_client_set_* functions

mongoc_client_set_ssl_opts and mongoc_client_set_ssl_stream_initiator

  • Changed in this PR to ignore a single-threaded client and log an error.

mongoc_client_set_sockettimeoutms

  • Not changed. Already documented to support a pooled client.

mongoc_client_set_write_concern, mongoc_client_set_read_concern, and mongoc_client_set_read_prefs

mongoc_client_set_apm_callbacks, mongoc_client_set_structured_log_opts, mongoc_client_set_error_api, mongoc_client_set_appname, mongoc_client_set_server_api

  • Not changed. Already error when passed a pooled client.

@kevinAlbs kevinAlbs marked this pull request as ready for review March 21, 2025 19:26
Copy link
Collaborator

@vector-of-bool vector-of-bool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevinAlbs kevinAlbs merged commit d33d253 into mongodb:master Apr 1, 2025
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants