|
@@ -33,10 +33,12 @@
|
|
|
#include "../../trim.h"
|
|
|
#include "../../globals.h"
|
|
|
#include "../../lib/srdb1/db.h"
|
|
|
+#include "../../timer.h"
|
|
|
|
|
|
#include "dbcl_data.h"
|
|
|
#include "dbcl_api.h"
|
|
|
|
|
|
+extern int dbcl_max_query_length;
|
|
|
|
|
|
#define DBCL_READ(command) \
|
|
|
do {\
|
|
@@ -44,6 +46,7 @@
|
|
|
int i;\
|
|
|
int j;\
|
|
|
int k;\
|
|
|
+ unsigned int sec = 0;\
|
|
|
db1_con_t *dbh=NULL;\
|
|
|
dbcl_cls_t *cls=NULL;\
|
|
|
cls = (dbcl_cls_t*)_h->tail;\
|
|
@@ -60,6 +63,7 @@
|
|
|
{\
|
|
|
LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
+ sec = get_ticks();\
|
|
|
dbh = cls->rlist[i].clist[j]->dbh;\
|
|
|
ret = cls->rlist[i].clist[j]->dbf.command;\
|
|
|
if (ret==0) {\
|
|
@@ -69,7 +73,10 @@
|
|
|
LM_DBG("serial operation - failre on cluster"\
|
|
|
" [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
- dbcl_inactive_con(cls->rlist[i].clist[j]);\
|
|
|
+ sec = get_ticks() - sec;\
|
|
|
+ if(sec >= dbcl_max_query_length){\
|
|
|
+ dbcl_inactive_con(cls->rlist[i].clist[j]);\
|
|
|
+ }\
|
|
|
}\
|
|
|
}\
|
|
|
}\
|
|
@@ -83,6 +90,7 @@
|
|
|
{\
|
|
|
LM_DBG("round robin operation - cluster [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
+ sec = get_ticks();\
|
|
|
dbh = cls->rlist[i].clist[j]->dbh;\
|
|
|
ret = cls->rlist[i].clist[j]->dbf.command;\
|
|
|
if (ret==0)\
|
|
@@ -94,7 +102,10 @@
|
|
|
LM_DBG("round robin operation - failre on cluster"\
|
|
|
" [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
- dbcl_inactive_con(cls->rlist[i].clist[j]);\
|
|
|
+ sec = get_ticks() - sec;\
|
|
|
+ if(sec >= dbcl_max_query_length){\
|
|
|
+ dbcl_inactive_con(cls->rlist[i].clist[j]);\
|
|
|
+ }\
|
|
|
}\
|
|
|
}\
|
|
|
}\
|
|
@@ -118,6 +129,7 @@
|
|
|
int i;\
|
|
|
int j;\
|
|
|
int k;\
|
|
|
+ unsigned int sec = 0;\
|
|
|
db1_con_t *dbh=NULL;\
|
|
|
dbcl_cls_t *cls=NULL;\
|
|
|
cls = (dbcl_cls_t*)_h->tail;\
|
|
@@ -136,6 +148,7 @@
|
|
|
{\
|
|
|
LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
+ sec = get_ticks();\
|
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
|
ret = cls->wlist[i].clist[j]->dbf.command;\
|
|
|
if (ret==0) {\
|
|
@@ -145,7 +158,10 @@
|
|
|
LM_DBG("serial operation - failure on cluster"\
|
|
|
" [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
- dbcl_inactive_con(cls->wlist[i].clist[j]);\
|
|
|
+ sec = get_ticks() - sec;\
|
|
|
+ if(sec >= dbcl_max_query_length){\
|
|
|
+ dbcl_inactive_con(cls->wlist[i].clist[j]);\
|
|
|
+ }\
|
|
|
}\
|
|
|
}\
|
|
|
}\
|
|
@@ -159,6 +175,7 @@
|
|
|
{\
|
|
|
LM_DBG("round robin operation - cluster [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
+ sec = get_ticks();\
|
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
|
ret = cls->wlist[i].clist[j]->dbf.command;\
|
|
|
if (ret==0)\
|
|
@@ -170,7 +187,10 @@
|
|
|
LM_DBG("round robin operation - failure on cluster"\
|
|
|
" [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
- dbcl_inactive_con(cls->wlist[i].clist[j]);\
|
|
|
+ sec = get_ticks() - sec;\
|
|
|
+ if(sec >= dbcl_max_query_length){\
|
|
|
+ dbcl_inactive_con(cls->wlist[i].clist[j]);\
|
|
|
+ }\
|
|
|
}\
|
|
|
}\
|
|
|
}\
|
|
@@ -183,6 +203,7 @@
|
|
|
{\
|
|
|
LM_DBG("parallel operation - cluster [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
+ sec = get_ticks();\
|
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
|
rc = cls->wlist[i].clist[j]->dbf.command;\
|
|
|
if(rc==0) {\
|
|
@@ -192,7 +213,10 @@
|
|
|
LM_DBG("parallel operation - failure on cluster"\
|
|
|
" [%.*s] (%d/%d)\n",\
|
|
|
cls->name.len, cls->name.s, i, j);\
|
|
|
- dbcl_inactive_con(cls->wlist[i].clist[j]);\
|
|
|
+ sec = get_ticks() - sec;\
|
|
|
+ if(sec >= dbcl_max_query_length){\
|
|
|
+ dbcl_inactive_con(cls->wlist[i].clist[j]);\
|
|
|
+ }\
|
|
|
}\
|
|
|
ret |= rc;\
|
|
|
}\
|