Skip to content

Commit

Permalink
[db_virtual] fix or flag propagation from db_virtual to other db back…
Browse files Browse the repository at this point in the history
…ends

	Nested connections under db_virtual were not receiving the
flags existing in the mother connection ( db_virtual connection ).
Because of this modules using OR operator for example ( like usrloc
and dialog ) were forced to used the default operator, AND thus
creating other queries than the ones desired.

Thanks to Chris Maciejewski <chris@level7systems.co.uk> for reporting

(cherry picked from commit 7b0bc82)
  • Loading branch information
ionutrazvanionita committed Mar 1, 2017
1 parent 4c8bebd commit 9c0e3a1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion modules/db_virtual/dbase.c
Expand Up @@ -138,6 +138,7 @@ do{
int i; \
int rc=0, rc2=1; \
int max_loop; \
int old_flags; \
handle_con_t * handle; \
db_func_t * f; \
handle_set_t * p = (handle_set_t*)_h->tail; \
Expand Down Expand Up @@ -165,9 +166,15 @@ do{
LM_DBG("flags1 = %i\n", p->con_list[p->curent_con].flags); \
\
\
\
old_flags = handle->con->flags; \
handle->con->flags |= _h->flags; \
/* call f*/ \
rc = f->FUNCTION_WITH_PARAMS; \
handle->con->flags = old_flags; \
/* in db core OR op is being reset after every db op so we \
* also have to reset it here */ \
CON_OR_RESET( _h ); \
\
if((rc && use_rc)){ \
LM_DBG("failover call failed\n"); \
/* set local can not use flag*/ \
Expand Down Expand Up @@ -520,6 +527,7 @@ int db_virtual_insert_update(const db_con_t* _h, const db_key_t* _k,
do { \
int mode; \
int rc=0; \
int old_flags; \
handle_con_t * handle; \
db_func_t * f; \
handle_set_t * p = (handle_set_t*)_h->tail; \
Expand Down Expand Up @@ -549,8 +557,16 @@ do {
LM_ERR("async not supported for this backend!\n"); \
return -1; \
} \
\
old_flags = handle->con->flags; \
handle->con->flags |= _h->flags; \
rc=f->FUNC(__VA_ARGS__); \
\
handle->con->flags = old_flags; \
/* in db core OR op is being reset after every db op so we \
* also have to reset it here */ \
CON_OR_RESET( _h ); \
\
if (rc<0) { \
/* FIXME quite a complicated case \
* if the db disconected by any means then \
Expand Down

0 comments on commit 9c0e3a1

Please sign in to comment.