Module: kamailio
Branch: master
Commit: 501c41dd35fb9f15fdf96f4f3778860395e37a84
URL:
https://github.com/kamailio/kamailio/commit/501c41dd35fb9f15fdf96f4f3778860…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-03-07T08:56:37+01:00
db_mongodb: re-init iterator and search again if fails to find from crt position
---
Modified: src/modules/db_mongodb/mongodb_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/501c41dd35fb9f15fdf96f4f3778860…
Patch:
https://github.com/kamailio/kamailio/commit/501c41dd35fb9f15fdf96f4f3778860…
---
diff --git a/src/modules/db_mongodb/mongodb_dbase.c
b/src/modules/db_mongodb/mongodb_dbase.c
index f4316ae..759b1c6 100644
--- a/src/modules/db_mongodb/mongodb_dbase.c
+++ b/src/modules/db_mongodb/mongodb_dbase.c
@@ -377,9 +377,16 @@ int db_mongodb_get_columns(const db1_con_t* _h, db1_res_t* _r)
LM_DBG("Found a field[%d] named: %s\n", col, colname);
if(mgres->colsdoc) {
if(!bson_iter_find(&riter, colname)) {
- LM_ERR("field [%s] not found in result iterator\n",
- colname);
- return -4;
+ /* re-init the iterator */
+ if (!bson_iter_init (&riter, mgres->rdoc)) {
+ LM_ERR("failed to initialize result iterator\n");
+ return -3;
+ }
+ if(!bson_iter_find(&riter, colname)) {
+ LM_ERR("field [%s] not found in result iterator\n",
+ colname);
+ return -4;
+ }
}
coltype = bson_iter_type(&riter);
} else {