Skip to content

Commit a1a677e

Browse files
committed
CDRIVER-630 apply connecttimeout to TLS handshake
1 parent 7c3e455 commit a1a677e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/mongoc/mongoc-client.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ mongoc_client_default_stream_initiator (const mongoc_uri_t *uri,
283283
const bson_t *options;
284284
bson_iter_t iter;
285285
const char *mechanism;
286+
int32_t connecttimeoutms = MONGOC_DEFAULT_CONNECTTIMEOUTMS;
286287
#endif
287288

288289
bson_return_val_if_fail (uri, NULL);
@@ -336,7 +337,12 @@ mongoc_client_default_stream_initiator (const mongoc_uri_t *uri,
336337
return NULL;
337338
}
338339

339-
if (!mongoc_stream_tls_do_handshake (base_stream, -1) ||
340+
if (bson_iter_init_find_case (&iter, options, "connecttimeoutms") &&
341+
BSON_ITER_HOLDS_INT32 (&iter)) {
342+
connecttimeoutms = bson_iter_int32 (&iter);
343+
}
344+
345+
if (!mongoc_stream_tls_do_handshake (base_stream, connecttimeoutms) ||
340346
!mongoc_stream_tls_check_cert (base_stream, host->host)) {
341347
bson_set_error (error,
342348
MONGOC_ERROR_STREAM,

0 commit comments

Comments
 (0)