Module: kamailio Branch: master Commit: c70d831aee5a95613de69568d8f1863788e0a074 URL: https://github.com/kamailio/kamailio/commit/c70d831aee5a95613de69568d8f1863788e0a074
Author: Victor Seva <[email protected]> Committer: Victor Seva <[email protected]> Date: 2018-04-14T17:29:25+02:00 ndb_mongodb: fix deprecation warning Since 1.5.0 mongoc_collection_find() is deprecated > http://mongoc.org/libmongoc/1.5.0/mongoc_collection_find.html --- Modified: src/modules/ndb_mongodb/mongodb_client.c --- Diff: https://github.com/kamailio/kamailio/commit/c70d831aee5a95613de69568d8f1863788e0a074.diff Patch: https://github.com/kamailio/kamailio/commit/c70d831aee5a95613de69568d8f1863788e0a074.patch --- diff --git a/src/modules/ndb_mongodb/mongodb_client.c b/src/modules/ndb_mongodb/mongodb_client.c index e74b8314f2..746c5876fd 100644 --- a/src/modules/ndb_mongodb/mongodb_client.c +++ b/src/modules/ndb_mongodb/mongodb_client.c @@ -216,9 +216,13 @@ int mongodbc_exec_cmd(str *srv, str *dname, str *cname, str *cmd, str *res, int bson_error_t error; bson_t command; bson_t reply; +#if MONGOC_CHECK_VERSION(1, 5, 0) + bson_t *opts; +#else + int nres; +#endif const bson_t *cdoc; char c; - int nres; int ret; if(srv==NULL || cmd==NULL || res==NULL) @@ -285,6 +289,20 @@ int mongodbc_exec_cmd(str *srv, str *dname, str *cname, str *cmd, str *res, int NULL, 0); } else { +#if MONGOC_CHECK_VERSION(1, 5, 0) + if(emode==3) opts = BCON_NEW("limit", BCON_INT32 (1)); + else opts = BCON_NEW("limit", BCON_INT32 (0)); + if(opts==NULL) { + LM_ERR("cannot initialize opts bson document\n"); + bson_destroy (&command); + goto error_exec; + } + rpl->cursor = mongoc_collection_find_with_opts (rpl->collection, + &command, + opts, + NULL); + bson_destroy (opts); +#else nres = 0; if(emode==3) nres = 1; /* return one result */ rpl->cursor = mongoc_collection_find (rpl->collection, @@ -295,6 +313,7 @@ int mongodbc_exec_cmd(str *srv, str *dname, str *cname, str *cmd, str *res, int &command, NULL, NULL); +#endif } bson_destroy (&command); if(rpl->cursor==NULL) { _______________________________________________ Kamailio (SER) - Development Mailing List [email protected] https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
