@@ -19,13 +19,16 @@ _test_has_readable_writable_server (bool pooled)
19
19
mongoc_read_prefs_t * prefs ;
20
20
bool r ;
21
21
bson_error_t error ;
22
+ mongoc_topology_t * topology ;
22
23
23
24
if (pooled ) {
24
25
pool = test_framework_client_pool_new ();
25
- td = & _mongoc_client_pool_get_topology (pool )-> description ;
26
+ topology = _mongoc_client_pool_get_topology (pool );
27
+ td = & topology -> description ;
26
28
} else {
27
29
client = test_framework_client_new ();
28
30
td = & client -> topology -> description ;
31
+ topology = client -> topology ;
29
32
}
30
33
31
34
prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY );
@@ -45,15 +48,21 @@ _test_has_readable_writable_server (bool pooled)
45
48
client , "admin" , tmp_bson ("{'ping': 1}" ), NULL , NULL , & error );
46
49
ASSERT_OR_PRINT (r , error );
47
50
51
+ bson_mutex_lock (& topology -> mutex );
48
52
ASSERT (mongoc_topology_description_has_writable_server (td ));
49
53
ASSERT (mongoc_topology_description_has_readable_server (td , NULL ));
54
+ bson_mutex_unlock (& topology -> mutex );
50
55
51
56
if (test_framework_is_replset ()) {
52
57
/* prefs still don't match any server */
58
+ bson_mutex_lock (& topology -> mutex );
53
59
ASSERT (!mongoc_topology_description_has_readable_server (td , prefs ));
60
+ bson_mutex_unlock (& topology -> mutex );
54
61
} else {
55
62
/* topology type single ignores read preference */
63
+ bson_mutex_lock (& topology -> mutex );
56
64
ASSERT (mongoc_topology_description_has_readable_server (td , prefs ));
65
+ bson_mutex_unlock (& topology -> mutex );
57
66
}
58
67
59
68
mongoc_read_prefs_destroy (prefs );
0 commit comments