@@ -116,7 +116,6 @@ _handle_not_primary_error (mongoc_cluster_t *cluster,
116
116
static void
117
117
_handle_network_error (mongoc_cluster_t * cluster ,
118
118
mongoc_server_stream_t * server_stream ,
119
- bool handshake_complete ,
120
119
const bson_error_t * why )
121
120
{
122
121
mongoc_topology_t * topology ;
@@ -135,7 +134,7 @@ _handle_network_error (mongoc_cluster_t *cluster,
135
134
136
135
_mongoc_topology_handle_app_error (topology ,
137
136
server_id ,
138
- handshake_complete ,
137
+ true, // handshake_complete
139
138
type ,
140
139
NULL ,
141
140
why ,
@@ -314,8 +313,7 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
314
313
cluster -> iov .len ,
315
314
cluster -> sockettimeoutms ,
316
315
error )) {
317
- _handle_network_error (
318
- cluster , cmd -> server_stream , true /* handshake complete */ , error );
316
+ _handle_network_error (cluster , cmd -> server_stream , error );
319
317
320
318
/* add info about the command to writev_full's error message */
321
319
RUN_CMD_ERR_DECORATE ;
@@ -331,24 +329,21 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
331
329
MONGOC_ERROR_STREAM_SOCKET ,
332
330
"socket error or timeout" );
333
331
334
- _handle_network_error (
335
- cluster , cmd -> server_stream , true /* handshake complete */ , error );
332
+ _handle_network_error (cluster , cmd -> server_stream , error );
336
333
GOTO (done );
337
334
}
338
335
339
336
memcpy (& msg_len , reply_header_buf , 4 );
340
337
msg_len = BSON_UINT32_FROM_LE (msg_len );
341
338
if ((msg_len < reply_header_size ) ||
342
339
(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 );
345
341
GOTO (done );
346
342
}
347
343
348
344
if (!_mongoc_rpc_scatter_reply_header_only (
349
345
& 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 );
352
347
GOTO (done );
353
348
}
354
349
doc_len = (size_t ) msg_len - reply_header_size ;
@@ -370,8 +365,7 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
370
365
RUN_CMD_ERR (MONGOC_ERROR_STREAM ,
371
366
MONGOC_ERROR_STREAM_SOCKET ,
372
367
"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 );
375
369
GOTO (done );
376
370
}
377
371
if (!_mongoc_rpc_scatter (& rpc , reply_buf , msg_len )) {
@@ -414,8 +408,7 @@ mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster,
414
408
RUN_CMD_ERR (MONGOC_ERROR_STREAM ,
415
409
MONGOC_ERROR_STREAM_SOCKET ,
416
410
"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 );
419
412
GOTO (done );
420
413
}
421
414
_mongoc_rpc_swab_from_le (& rpc );
@@ -3302,8 +3295,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
3302
3295
MONGOC_DEBUG (
3303
3296
"Could not read 4 bytes, stream probably closed or timed out" );
3304
3297
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 );
3307
3299
RETURN (false);
3308
3300
}
3309
3301
@@ -3318,8 +3310,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
3318
3310
MONGOC_ERROR_PROTOCOL ,
3319
3311
MONGOC_ERROR_PROTOCOL_INVALID_REPLY ,
3320
3312
"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 );
3323
3314
mongoc_counter_protocol_ingress_error_inc ();
3324
3315
RETURN (false);
3325
3316
}
@@ -3332,8 +3323,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
3332
3323
msg_len - 4 ,
3333
3324
cluster -> sockettimeoutms ,
3334
3325
error )) {
3335
- _handle_network_error (
3336
- cluster , server_stream , true /* handshake complete */ , error );
3326
+ _handle_network_error (cluster , server_stream , error );
3337
3327
mongoc_counter_protocol_ingress_error_inc ();
3338
3328
RETURN (false);
3339
3329
}
@@ -3346,8 +3336,7 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
3346
3336
MONGOC_ERROR_PROTOCOL ,
3347
3337
MONGOC_ERROR_PROTOCOL_INVALID_REPLY ,
3348
3338
"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 );
3351
3340
mongoc_counter_protocol_ingress_error_inc ();
3352
3341
RETURN (false);
3353
3342
}
@@ -3506,8 +3495,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
3506
3495
if (!ok ) {
3507
3496
/* add info about the command to writev_full's error message */
3508
3497
RUN_CMD_ERR_DECORATE ;
3509
- _handle_network_error (
3510
- cluster , server_stream , true /* handshake complete */ , error );
3498
+ _handle_network_error (cluster , server_stream , error );
3511
3499
server_stream -> stream = NULL ;
3512
3500
bson_free (output );
3513
3501
network_error_reply (reply , cmd );
@@ -3521,8 +3509,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
3521
3509
& buffer , server_stream -> stream , 4 , cluster -> sockettimeoutms , error );
3522
3510
if (!ok ) {
3523
3511
RUN_CMD_ERR_DECORATE ;
3524
- _handle_network_error (
3525
- cluster , server_stream , true /* handshake complete */ , error );
3512
+ _handle_network_error (cluster , server_stream , error );
3526
3513
server_stream -> stream = NULL ;
3527
3514
bson_free (output );
3528
3515
network_error_reply (reply , cmd );
@@ -3540,8 +3527,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
3540
3527
"Message size %d is not within expected range 16-%d bytes" ,
3541
3528
msg_len ,
3542
3529
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 );
3545
3531
server_stream -> stream = NULL ;
3546
3532
bson_free (output );
3547
3533
network_error_reply (reply , cmd );
@@ -3556,8 +3542,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
3556
3542
error );
3557
3543
if (!ok ) {
3558
3544
RUN_CMD_ERR_DECORATE ;
3559
- _handle_network_error (
3560
- cluster , server_stream , true /* handshake complete */ , error );
3545
+ _handle_network_error (cluster , server_stream , error );
3561
3546
server_stream -> stream = NULL ;
3562
3547
bson_free (output );
3563
3548
network_error_reply (reply , cmd );
@@ -3584,8 +3569,7 @@ mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster,
3584
3569
RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL ,
3585
3570
MONGOC_ERROR_PROTOCOL_INVALID_REPLY ,
3586
3571
"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 );
3589
3573
server_stream -> stream = NULL ;
3590
3574
bson_free (output );
3591
3575
network_error_reply (reply , cmd );
0 commit comments