Skip to content

Commit 2493b96

Browse files
samantharitterkevinAlbs
authored andcommitted
CDRIVER-3318 add test for ssl hang
1 parent 928775c commit 2493b96

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/libmongoc/tests/test-mongoc-client.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,37 @@ test_ssl_pooled (void)
23122312
{
23132313
_test_mongoc_client_ssl_opts (true);
23142314
}
2315+
2316+
static void
2317+
test_client_buildinfo_hang (void)
2318+
{
2319+
mongoc_client_pool_t *pool;
2320+
mongoc_client_t *client;
2321+
mongoc_database_t *database;
2322+
bson_error_t error;
2323+
bson_t command;
2324+
bson_t reply;
2325+
2326+
pool = test_framework_client_pool_new ();
2327+
BSON_ASSERT (pool);
2328+
client = mongoc_client_pool_pop (pool);
2329+
2330+
database = mongoc_client_get_database (client, "admin");
2331+
bson_init (&command);
2332+
bson_append_int32 (&command, "buildInfo", -1, 1);
2333+
2334+
/* Prior to a bug fix this command caused a hang - see CDRIVER-3318 */
2335+
ASSERT_OR_PRINT (
2336+
mongoc_database_command_simple (database, &command, NULL, &reply, &error),
2337+
error);
2338+
2339+
bson_destroy (&command);
2340+
bson_destroy (&reply);
2341+
mongoc_database_destroy (database);
2342+
mongoc_client_destroy (client);
2343+
mongoc_client_pool_destroy (pool);
2344+
}
2345+
23152346
#else
23162347
/* MONGOC_ENABLE_SSL is not defined */
23172348
static void
@@ -3842,6 +3873,9 @@ test_client_install (TestSuite *suite)
38423873
suite, "/Client/ssl/reconnect/single", test_ssl_reconnect_single);
38433874
TestSuite_AddMockServerTest (
38443875
suite, "/Client/ssl/reconnect/pooled", test_ssl_reconnect_pooled);
3876+
3877+
TestSuite_AddLive (suite, "/Client/ssl_hang", test_client_buildinfo_hang);
3878+
38453879
#endif
38463880
#else
38473881
/* No SSL support at all */

0 commit comments

Comments
 (0)