Skip to content

Commit 979f1c1

Browse files
committed
cluster: set proper error if we fail to locate a node.
This could happen if read preferences prevent finding a suitable node.
1 parent 022bc04 commit 979f1c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/mongoc/mongoc-cluster.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,17 @@ _mongoc_cluster_select (mongoc_cluster_t *cluster,
775775
}
776776
}
777777

778+
/*
779+
* Mark the error as unable to locate a target node.
780+
*/
781+
if (!count) {
782+
bson_set_error (error,
783+
MONGOC_ERROR_CLIENT,
784+
MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER,
785+
"Failed to locate a suitable MongoDB node.");
786+
RETURN (NULL);
787+
}
788+
778789
/*
779790
* Choose a cluster node within threshold at random.
780791
*/

0 commit comments

Comments
 (0)