From b2f957dc8e254371cd7c985dd00bbfbc2aa38c18 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sat, 23 Jun 2018 21:14:03 +0900 Subject: [PATCH] fix the compiler error in the mongo-c-driver 1.11 --- src/app/context.c | 26 +++++++++++++++++++++++++- test/Makefile.am | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/app/context.c b/src/app/context.c index 8b2cd3a29..cb39d08fc 100644 --- a/src/app/context.c +++ b/src/app/context.c @@ -301,6 +301,29 @@ status_t context_parse_config() return CORE_OK; } +/* + * We've added it + * Because the following function is deprecated in the mongo-c-driver + */ +static bool +context_mongoc_client_get_server_status (mongoc_client_t *client, /* IN */ + mongoc_read_prefs_t *read_prefs, /* IN */ + bson_t *reply, /* OUT */ + bson_error_t *error) /* OUT */ +{ + bson_t cmd = BSON_INITIALIZER; + bool ret = false; + + BSON_ASSERT (client); + + BSON_APPEND_INT32 (&cmd, "serverStatus", 1); + ret = mongoc_client_command_simple ( + client, "admin", &cmd, read_prefs, reply, error); + bson_destroy (&cmd); + + return ret; +} + status_t context_db_init(const char *db_uri) { bson_t reply; @@ -334,7 +357,8 @@ status_t context_db_init(const char *db_uri) d_assert(self.database, context_db_final(); return CORE_ERROR, "Database is not defined in DB_URI [%s]", db_uri); - if (!mongoc_client_get_server_status(self.db_client, NULL, &reply, &error)) + if (!context_mongoc_client_get_server_status( + self.db_client, NULL, &reply, &error)) { d_error("Failed to conect to server [%s]", db_uri); return CORE_EAGAIN; diff --git a/test/Makefile.am b/test/Makefile.am index 7807cfb5d..c3cdbdd50 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -40,7 +40,7 @@ AM_CPPFLAGS = \ AM_CFLAGS = \ -Wall -Werror \ - -Wno-unused-function -Wno-unused-variable \ + -Wno-unused-function -Wno-unused-variable -Wno-deprecated-declarations \ @OSCPPFLAGS@ \ $(NULL)