Skip to content

Commit a74550f

Browse files
committed
various fixups for memory leaks and races in tests
1 parent 5fa8774 commit a74550f

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

tests/mock-server.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,14 +546,19 @@ mock_server_quit (mock_server_t *server)
546546
assert (0 == mongoc_stream_close (stream)); /* success */
547547
}
548548
}
549-
mongoc_cond_wait (&server->stopped_condition, &server->mutex);
549+
while (! server->stopped) {
550+
mongoc_cond_wait (&server->stopped_condition, &server->mutex);
551+
}
550552
mongoc_mutex_unlock (&server->mutex);
551553
}
552554

553555

554556
void
555557
mock_server_destroy (mock_server_t *server)
556558
{
559+
/* TODO: we can't actually destroy these if workers are still around. Make
560+
* this operational again after fixing that up */
561+
return;
557562
if (server) {
558563
_mongoc_array_destroy (&server->streams);
559564
mongoc_cond_destroy (&server->cond);

tests/test-mongoc-cluster.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ call_ismaster (bson_t *reply)
2222
r = mongoc_client_command_simple (client, "admin", &ismaster,
2323
NULL, reply, NULL);
2424

25+
mongoc_client_destroy(client);
26+
2527
assert (r);
2628
}
2729

@@ -72,6 +74,7 @@ uri_from_ismaster_plus_one (bson_t *ismaster_response)
7274
char *name;
7375
bson_iter_t iter;
7476
bson_iter_t hosts_iter;
77+
mongoc_uri_t *uri;
7578

7679
if ((name = set_name (ismaster_response))) {
7780
bson_iter_init_find (&iter, ismaster_response, "hosts");
@@ -98,7 +101,11 @@ uri_from_ismaster_plus_one (bson_t *ismaster_response)
98101
bson_free (host);
99102
}
100103

101-
return mongoc_uri_new (bson_string_free (uri_str, false));
104+
uri = mongoc_uri_new (uri_str->str);
105+
106+
bson_string_free (uri_str, true);
107+
108+
return uri;
102109
}
103110

104111

valgrind.suppressions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
{
2626
ingore_scram_nonce_uninitialized_warning_cond
2727
Memcheck:Cond
28-
fun:b64_ntop
28+
fun:mongoc_b64_ntop
2929
...
3030
fun:_mongoc_scram_step
3131
...
3232
}
3333
{
3434
ingore_scram_nonce_uninitialized_warning_value8
3535
Memcheck:Value8
36-
fun:b64_ntop
36+
fun:mongoc_b64_ntop
3737
...
3838
fun:_mongoc_scram_step
3939
...

0 commit comments

Comments
 (0)