Skip to content

Commit 55ee43f

Browse files
ajdavisbjori
authored andcommitted
CDRIVER-1567 swap connection err / timeout msgs
1 parent ff1ce0a commit 55ee43f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/mongoc/mongoc-topology-scanner.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,17 @@ mongoc_topology_scanner_ismaster_handler (mongoc_async_cmd_result_t async_status
277277
mongoc_stream_failed (node->stream);
278278
node->stream = NULL;
279279
node->last_failed = now;
280-
message = async_status == MONGOC_ASYNC_CMD_TIMEOUT ?
281-
"connection error" :
282-
"connection timeout";
280+
281+
if (error->code) {
282+
message = error->message;
283+
} else {
284+
if (async_status == MONGOC_ASYNC_CMD_TIMEOUT) {
285+
message = "connection timeout";
286+
} else {
287+
message = "connection error";
288+
}
289+
}
290+
283291
bson_set_error (&node->last_error,
284292
MONGOC_ERROR_CLIENT,
285293
MONGOC_ERROR_STREAM_CONNECT,

tests/test-mongoc-topology-scanner.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "mock_server/mock-rs.h"
1212
#include "mock_server/future.h"
1313
#include "mock_server/future-functions.h"
14+
#include "test-conveniences.h"
1415

1516
#undef MONGOC_LOG_DOMAIN
1617
#define MONGOC_LOG_DOMAIN "topology-scanner-test"

0 commit comments

Comments
 (0)