Skip to content

Commit

Permalink
Fixed reporting the correct query retcode via db_virtual
Browse files Browse the repository at this point in the history
There are mainly 2 fixes here:
- correct iteration in the list of connection when failed conns are found or detected
- correct aggregation of the retcode, based on all performed queries in the list

(cherry picked from commit 8369c31)
  • Loading branch information
bogdan-iancu authored and razvancrainea committed Aug 14, 2018
1 parent fd4dcff commit 8ce861d
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions modules/db_virtual/dbase.c
Expand Up @@ -180,20 +180,22 @@ do{
/* set local can not use flag*/ \
handle->flags &= NOT_CAN_USE; \
\
\
/* close connection*/ \
f->close(handle->con); \
\
/* move to the next conn */ \
p->curent_con = (p->curent_con+1)%p->size; \
} \
set_update_flags(p->curent_con, p); \
}else{ \
LM_DBG("flags2 = %i\n", p->con_list[p->curent_con].flags); \
\
/* try next*/ \
rc = 1; \
rc = -1; \
p->curent_con = (p->curent_con+1)%p->size; \
} \
LM_DBG("curent_con = %i\n", p->curent_con); \
}while((rc && use_rc) && max_loop--); \
}while((rc && use_rc) && --max_loop); \
\
rc2=rc; \
break; \
Expand All @@ -205,14 +207,11 @@ do{
f = &global->set_list[p->set_index].db_list[i].dbf; \
if((handle->flags & CAN_USE) && (handle->flags & MAY_USE)){ \
\
\
rc = f->FUNCTION_WITH_PARAMS; \
if((rc && use_rc)){ \
LM_DBG("parallel call failed\n"); \
handle->flags &= NOT_CAN_USE; \
\
\
\
f->close(handle->con); \
} \
set_update_flags(i, p); \
Expand All @@ -226,20 +225,16 @@ do{
else \
rc2 = rc; \
\
\
\
} \
}else{ \
do{ \
do{ \
/* get next valid handle*/ \
handle = &p->con_list[p->curent_con]; \
f = &global->set_list[p->set_index].db_list[p->curent_con].dbf; \
\
if((handle->flags & CAN_USE) && (handle->flags & MAY_USE)){ \
LM_DBG("flags1 = %i\n", p->con_list[p->curent_con].flags); \
\
\
\
/* call f*/ \
rc = f->FUNCTION_WITH_PARAMS; \
if(rc){ \
Expand All @@ -251,16 +246,19 @@ do{
\
/* close connection*/ \
f->close(handle->con); \
\
/* move to the next conn */ \
p->curent_con = (p->curent_con+1)%p->size; \
} \
}else{ \
LM_DBG("flags2 = %i\n", p->con_list[p->curent_con].flags); \
\
/* try next*/ \
rc = 1; \
rc = -1; \
p->curent_con = (p->curent_con+1)%p->size; \
} \
LM_DBG("curent_con = %i\n", p->curent_con); \
}while((rc && use_rc) && max_loop--); \
}while((rc && use_rc) && --max_loop); \
\
rc2=rc ; \
} \
Expand Down

0 comments on commit 8ce861d

Please sign in to comment.