Kaynağa Gözat

ndb_mongodb: mongoc_collection_command_with_opts() for mongodb_cmd()

- mongoc_collection_command() is deprecated with lib v1.29.0
- GH #4037

(cherry picked from commit 3991350b1acdcd8b3cd575cdbc8932b4f8540e13)
Daniel-Constantin Mierla 9 ay önce
ebeveyn
işleme
076fb25f51
1 değiştirilmiş dosya ile 20 ekleme ve 0 silme
  1. 20 0
      src/modules/ndb_mongodb/mongodb_client.c

+ 20 - 0
src/modules/ndb_mongodb/mongodb_client.c

@@ -274,8 +274,24 @@ int mongodbc_exec_cmd(
 		bson_destroy(&reply);
 	} else {
 		if(emode == 1) {
+#if MONGOC_CHECK_VERSION(1, 29, 0)
+			opts = bson_new();
+			ret = mongoc_collection_command_with_opts(
+					rpl->collection, &command, NULL, opts, &reply, &error);
+			bson_free(opts);
+			if(!ret) {
+				LM_ERR("Failed to run command: %s\n", error.message);
+				bson_destroy(&command);
+				goto error_exec;
+			}
+			rpl->jsonrpl.s = _ksr_bson_as_json(&reply, NULL);
+			rpl->jsonrpl.len = (rpl->jsonrpl.s) ? strlen(rpl->jsonrpl.s) : 0;
+			bson_destroy(&reply);
+			goto done;
+#else
 			rpl->cursor = mongoc_collection_command(rpl->collection,
 					MONGOC_QUERY_NONE, 0, 0, 0, &command, NULL, 0);
+#endif
 		} else {
 #if MONGOC_CHECK_VERSION(1, 5, 0)
 			if(emode == 3)
@@ -313,6 +329,10 @@ int mongodbc_exec_cmd(
 		rpl->jsonrpl.len = (rpl->jsonrpl.s) ? strlen(rpl->jsonrpl.s) : 0;
 	}
 
+#if MONGOC_CHECK_VERSION(1, 29, 0)
+done:
+#endif
+
 	LM_DBG("command result: [[%s]]\n",
 			(rpl->jsonrpl.s) ? rpl->jsonrpl.s : "<null>");