@@ -38,10 +38,6 @@ mongoc_server_description_cleanup (mongoc_server_description_t *sd)
38
38
{
39
39
BSON_ASSERT (sd );
40
40
41
- if (sd -> error ) {
42
- bson_free ((void * )sd -> error );
43
- }
44
-
45
41
bson_destroy (& sd -> last_is_master );
46
42
}
47
43
@@ -52,11 +48,6 @@ mongoc_server_description_reset (mongoc_server_description_t *sd)
52
48
{
53
49
BSON_ASSERT (sd );
54
50
55
- if (sd -> error ) {
56
- bson_free ((void * )sd -> error );
57
- sd -> error = NULL ;
58
- }
59
-
60
51
/* set other fields to default or empty states */
61
52
memset (& sd -> set_name , 0 , sizeof (* sd ) - ((char * )& sd -> set_name - (char * )sd ));
62
53
sd -> set_name = NULL ;
@@ -106,7 +97,6 @@ mongoc_server_description_init (mongoc_server_description_t *sd,
106
97
sd -> round_trip_time = -1 ;
107
98
108
99
sd -> set_name = NULL ;
109
- sd -> error = NULL ;
110
100
sd -> current_primary = NULL ;
111
101
112
102
if (!_mongoc_host_list_from_string (& sd -> host , address )) {
@@ -442,7 +432,6 @@ mongoc_server_description_new_copy (const mongoc_server_description_t *descripti
442
432
copy -> round_trip_time = -1 ;
443
433
444
434
copy -> connection_address = copy -> host .host_and_port ;
445
- copy -> error = bson_strdup (description -> error );
446
435
447
436
/* wait for handle_ismaster to fill these in properly */
448
437
copy -> has_is_master = false;
@@ -457,6 +446,8 @@ mongoc_server_description_new_copy (const mongoc_server_description_t *descripti
457
446
mongoc_server_description_handle_ismaster (copy , & description -> last_is_master ,
458
447
description -> round_trip_time , NULL );
459
448
}
449
+ /* Preserve the error */
450
+ memcpy (& copy -> error , & description -> error , sizeof copy -> error );
460
451
return copy ;
461
452
}
462
453
0 commit comments