Module: kamailio
Branch: 5.1
Commit: 63c93af189e7e5db92a392e0d176e71bda64290e
URL:
https://github.com/kamailio/kamailio/commit/63c93af189e7e5db92a392e0d176e71…
Author: kelchy <kelchy(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-03-14T11:24:06+01:00
db_mongodb: add error logger for failed query
(cherry picked from commit 2a5d66fda013197aa5fbe4828cc7f6e61a74a9d6)
---
Modified: src/modules/db_mongodb/mongodb_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/63c93af189e7e5db92a392e0d176e71…
Patch:
https://github.com/kamailio/kamailio/commit/63c93af189e7e5db92a392e0d176e71…
---
diff --git a/src/modules/db_mongodb/mongodb_dbase.c
b/src/modules/db_mongodb/mongodb_dbase.c
index b1c9ac2bb7..aee5a1ba0a 100644
--- a/src/modules/db_mongodb/mongodb_dbase.c
+++ b/src/modules/db_mongodb/mongodb_dbase.c
@@ -753,6 +753,7 @@ static int db_mongodb_store_result(const db1_con_t* _h, db1_res_t**
_r)
km_mongodb_con_t *mgcon;
db_mongodb_result_t *mgres;
const bson_t *itdoc;
+ bson_error_t error;
mgcon = MONGODB_CON(_h);
if(!_r) {
@@ -777,7 +778,11 @@ static int db_mongodb_store_result(const db1_con_t* _h, db1_res_t**
_r)
if(!mongoc_cursor_more (mgres->cursor)
|| !mongoc_cursor_next (mgres->cursor, &itdoc)
|| !itdoc) {
- LM_DBG("no result from mongodb\n");
+ if (mongoc_cursor_error (mgres->cursor, &error)) {
+ LM_DBG("An error occurred: %s\n", error.message);
+ } else {
+ LM_DBG("no result from mongodb\n");
+ }
return 0;
}
/* first document linked internally in result to get columns */