Skip to content

Commit 2013c9c

Browse files
committed
CDRIVER-696: Make the (currently unused) error field bson_error_t
1 parent 7b16136 commit 2013c9c

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/mongoc/mongoc-server-description-private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct _mongoc_server_description_t
5252
/* The following fields are filled from the last_is_master and are zeroed on
5353
* parse. So order matters here. DON'T move set_name */
5454
const char *set_name;
55-
const char *error;
55+
bson_error_t error;
5656
mongoc_server_description_type_t type;
5757

5858
int32_t min_wire_version;

src/mongoc/mongoc-server-description.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ mongoc_server_description_cleanup (mongoc_server_description_t *sd)
3838
{
3939
BSON_ASSERT(sd);
4040

41-
if (sd->error) {
42-
bson_free ((void *)sd->error);
43-
}
44-
4541
bson_destroy (&sd->last_is_master);
4642
}
4743

@@ -52,11 +48,6 @@ mongoc_server_description_reset (mongoc_server_description_t *sd)
5248
{
5349
BSON_ASSERT(sd);
5450

55-
if (sd->error) {
56-
bson_free ((void *)sd->error);
57-
sd->error = NULL;
58-
}
59-
6051
/* set other fields to default or empty states */
6152
memset (&sd->set_name, 0, sizeof (*sd) - ((char*)&sd->set_name - (char*)sd));
6253
sd->set_name = NULL;
@@ -106,7 +97,6 @@ mongoc_server_description_init (mongoc_server_description_t *sd,
10697
sd->round_trip_time = -1;
10798

10899
sd->set_name = NULL;
109-
sd->error = NULL;
110100
sd->current_primary = NULL;
111101

112102
if (!_mongoc_host_list_from_string(&sd->host, address)) {
@@ -442,7 +432,6 @@ mongoc_server_description_new_copy (const mongoc_server_description_t *descripti
442432
copy->round_trip_time = -1;
443433

444434
copy->connection_address = copy->host.host_and_port;
445-
copy->error = bson_strdup (description->error);
446435

447436
/* wait for handle_ismaster to fill these in properly */
448437
copy->has_is_master = false;
@@ -457,6 +446,8 @@ mongoc_server_description_new_copy (const mongoc_server_description_t *descripti
457446
mongoc_server_description_handle_ismaster (copy, &description->last_is_master,
458447
description->round_trip_time, NULL);
459448
}
449+
/* Preserve the error */
450+
memcpy (&copy->error, &description->error, sizeof copy->error);
460451
return copy;
461452
}
462453

0 commit comments

Comments
 (0)