Skip to content

Commit 5283082

Browse files
committed
Remove always-true handshake_complete parameter from _handle_network_error
1 parent aac2054 commit 5283082

File tree

1 file changed

+16
-32
lines changed

1 file changed

+16
-32
lines changed

src/libmongoc/src/mongoc/mongoc-cluster.c

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ _handle_not_primary_error (mongoc_cluster_t *cluster,
116116
static void
117117
_handle_network_error (mongoc_cluster_t *cluster,
118118
mongoc_server_stream_t *server_stream,
119-
bool handshake_complete,
120119
const bson_error_t *why)
121120
{
122121
mongoc_topology_t *topology;
@@ -135,7 +134,7 @@ _handle_network_error (mongoc_cluster_t *cluster,
135134

136135
_mongoc_topology_handle_app_error (topology,
137136
server_id,
138-
handshake_complete,
137+
true, // handshake_complete
139138
type,
140139
NULL,
141140
why,
@@ -314,8 +313,7 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
314313
cluster->iov.len,
315314
cluster->sockettimeoutms,
316315
error)) {
317-
_handle_network_error (
318-
cluster, cmd->server_stream, true /* handshake complete */, error);
316+
_handle_network_error (cluster, cmd->server_stream, error);
319317

320318
/* add info about the command to writev_full's error message */
321319
RUN_CMD_ERR_DECORATE;
@@ -331,24 +329,21 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
331329
MONGOC_ERROR_STREAM_SOCKET,
332330
"socket error or timeout");
333331

334-
_handle_network_error (
335-
cluster, cmd->server_stream, true /* handshake complete */, error);
332+
_handle_network_error (cluster, cmd->server_stream, error);
336333
GOTO (done);
337334
}
338335

339336
memcpy (&msg_len, reply_header_buf, 4);
340337
msg_len = BSON_UINT32_FROM_LE (msg_len);
341338
if ((msg_len < reply_header_size) ||
342339
(msg_len > MONGOC_DEFAULT_MAX_MSG_SIZE)) {
343-
_handle_network_error (
344-
cluster, cmd->server_stream, true /* handshake complete */, error);
340+
_handle_network_error (cluster, cmd->server_stream, error);
345341
GOTO (done);
346342
}
347343

348344
if (!_mongoc_rpc_scatter_reply_header_only (
349345
&rpc, reply_header_buf, reply_header_size)) {
350-
_handle_network_error (
351-
cluster, cmd->server_stream, true /* handshake complete */, error);
346+
_handle_network_error (cluster, cmd->server_stream, error);
352347
GOTO (done);
353348
}
354349
doc_len = (size_t) msg_len - reply_header_size;
@@ -370,8 +365,7 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
370365
RUN_CMD_ERR (MONGOC_ERROR_STREAM,
371366
MONGOC_ERROR_STREAM_SOCKET,
372367
"socket error or timeout");
373-
_handle_network_error (
374-
cluster, cmd->server_stream, true /* handshake complete */, error);
368+
_handle_network_error (cluster, cmd->server_stream, error);
375369
GOTO (done);
376370
}
377371
if (!_mongoc_rpc_scatter (&rpc, reply_buf, msg_len)) {
@@ -414,8 +408,7 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
414408
RUN_CMD_ERR (MONGOC_ERROR_STREAM,
415409
MONGOC_ERROR_STREAM_SOCKET,
416410
"socket error or timeout");
417-
_handle_network_error (
418-
cluster, cmd->server_stream, true /* handshake complete */, error);
411+
_handle_network_error (cluster, cmd->server_stream, error);
419412
GOTO (done);
420413
}
421414
_mongoc_rpc_swab_from_le (&rpc);
@@ -3302,8 +3295,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
33023295
MONGOC_DEBUG (
33033296
"Could not read 4 bytes, stream probably closed or timed out");
33043297
mongoc_counter_protocol_ingress_error_inc ();
3305-
_handle_network_error (
3306-
cluster, server_stream, true /* handshake complete */, error);
3298+
_handle_network_error (cluster, server_stream, error);
33073299
RETURN (false);
33083300
}
33093301

@@ -3318,8 +3310,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
33183310
MONGOC_ERROR_PROTOCOL,
33193311
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
33203312
"Corrupt or malicious reply received.");
3321-
_handle_network_error (
3322-
cluster, server_stream, true /* handshake complete */, error);
3313+
_handle_network_error (cluster, server_stream, error);
33233314
mongoc_counter_protocol_ingress_error_inc ();
33243315
RETURN (false);
33253316
}
@@ -3332,8 +3323,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
33323323
msg_len - 4,
33333324
cluster->sockettimeoutms,
33343325
error)) {
3335-
_handle_network_error (
3336-
cluster, server_stream, true /* handshake complete */, error);
3326+
_handle_network_error (cluster, server_stream, error);
33373327
mongoc_counter_protocol_ingress_error_inc ();
33383328
RETURN (false);
33393329
}
@@ -3346,8 +3336,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
33463336
MONGOC_ERROR_PROTOCOL,
33473337
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
33483338
"Failed to decode reply from server.");
3349-
_handle_network_error (
3350-
cluster, server_stream, true /* handshake complete */, error);
3339+
_handle_network_error (cluster, server_stream, error);
33513340
mongoc_counter_protocol_ingress_error_inc ();
33523341
RETURN (false);
33533342
}
@@ -3506,8 +3495,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
35063495
if (!ok) {
35073496
/* add info about the command to writev_full's error message */
35083497
RUN_CMD_ERR_DECORATE;
3509-
_handle_network_error (
3510-
cluster, server_stream, true /* handshake complete */, error);
3498+
_handle_network_error (cluster, server_stream, error);
35113499
server_stream->stream = NULL;
35123500
bson_free (output);
35133501
network_error_reply (reply, cmd);
@@ -3521,8 +3509,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
35213509
&buffer, server_stream->stream, 4, cluster->sockettimeoutms, error);
35223510
if (!ok) {
35233511
RUN_CMD_ERR_DECORATE;
3524-
_handle_network_error (
3525-
cluster, server_stream, true /* handshake complete */, error);
3512+
_handle_network_error (cluster, server_stream, error);
35263513
server_stream->stream = NULL;
35273514
bson_free (output);
35283515
network_error_reply (reply, cmd);
@@ -3540,8 +3527,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
35403527
"Message size %d is not within expected range 16-%d bytes",
35413528
msg_len,
35423529
server_stream->sd->max_msg_size);
3543-
_handle_network_error (
3544-
cluster, server_stream, true /* handshake complete */, error);
3530+
_handle_network_error (cluster, server_stream, error);
35453531
server_stream->stream = NULL;
35463532
bson_free (output);
35473533
network_error_reply (reply, cmd);
@@ -3556,8 +3542,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
35563542
error);
35573543
if (!ok) {
35583544
RUN_CMD_ERR_DECORATE;
3559-
_handle_network_error (
3560-
cluster, server_stream, true /* handshake complete */, error);
3545+
_handle_network_error (cluster, server_stream, error);
35613546
server_stream->stream = NULL;
35623547
bson_free (output);
35633548
network_error_reply (reply, cmd);
@@ -3584,8 +3569,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
35843569
RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL,
35853570
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
35863571
"Could not decompress message from server");
3587-
_handle_network_error (
3588-
cluster, server_stream, true /* handshake complete */, error);
3572+
_handle_network_error (cluster, server_stream, error);
35893573
server_stream->stream = NULL;
35903574
bson_free (output);
35913575
network_error_reply (reply, cmd);

0 commit comments

Comments
 (0)