From 57bd8b6c3d4dd6328536dea4de55e41734e1e021 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 11 Oct 2007 07:22:02 +0000 Subject: [PATCH] Proxy module still build - switch to new DB module too. --- org.glite.lb.proxy/Makefile | 13 +------------ org.glite.lb.proxy/src/lbproxy.c | 40 +++++++++++++++++++++++++------------- org.glite.lb.server-bones/Makefile | 6 +++--- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/org.glite.lb.proxy/Makefile b/org.glite.lb.proxy/Makefile index 04dd6cf..c24660a 100644 --- a/org.glite.lb.proxy/Makefile +++ b/org.glite.lb.proxy/Makefile @@ -44,7 +44,6 @@ CFLAGS:= ${DEBUG} \ -I${stagedir}/include -I${top_srcdir}/src -I. \ -I${expat_prefix}/include \ ${COVERAGE_FLAGS} \ - -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql \ -I${gridsite_prefix}/include \ -D_GNU_SOURCE ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} @@ -60,14 +59,6 @@ ifeq (${host_cpu},x86_64) archlib:=lib64 endif -ifneq (${mysql_prefix},/usr) - ifeq ($(shell echo ${mysql_version} | cut -d. -f1,2),4.1) - mysqlib := -L${mysql_prefix}/${archlib}/mysql - else - mysqlib := -L${mysql_prefix}/${archlib} - endif -endif - ifneq (${expat_prefix},/usr) expatlib := -L${expat_prefix}/lib endif @@ -86,7 +77,6 @@ endif VOMS_LIBS:=-L${voms_prefix}/lib -lvomsc${vomsflavour} EXT_LIBS:= \ - ${mysqlib} -lmysqlclient -lz\ ${expatlib} -lexpat \ ${GRIDSITE_LIBS} \ ${VOMS_LIBS} @@ -97,14 +87,13 @@ LB_PROXY_LIBS:= \ ${STATIC_LIB_BK} \ ${SRVBONES_LIB} \ -lglite_lb_common_${nothrflavour} \ + -lglite_lbu_db \ -lglite_security_gss_${nothrflavour} \ ${EXT_LIBS} glite-lb-proxy: lbproxy.o fake_write2rgma.o ${STATIC_LIB_BK} - @echo DEBUG: mysql_version=${mysql_version} mysql_prefix=${mysql_prefix} - @echo DEBUG: shell: x$(shell echo ${mysql_version} | cut -d. -f1,2)x ${LINK} -o $@ lbproxy.o fake_write2rgma.o ${LB_PROXY_LIBS} glite-lb-proxy-perf: lbproxy.o fake_write2rgma.o ${STATIC_LIB_BK} diff --git a/org.glite.lb.proxy/src/lbproxy.c b/org.glite.lb.proxy/src/lbproxy.c index e976079..5b8616a 100644 --- a/org.glite.lb.proxy/src/lbproxy.c +++ b/org.glite.lb.proxy/src/lbproxy.c @@ -81,6 +81,7 @@ static int slaves = 10, static char host[300]; static char * port; int transactions = -1; +int use_dbcaps = 0; static struct option opts[] = { @@ -155,7 +156,8 @@ static struct glite_srvbones_service service_table[] = { struct clnt_data_t { edg_wll_Context ctx; - void *mysql; + glite_lbu_DBContext dbctx; + int dbcaps; }; @@ -175,7 +177,6 @@ int main(int argc, char *argv[]) int silent = 0; - name = strrchr(argv[0],'/'); if (name) name++; else name = argv[0]; @@ -307,20 +308,31 @@ int main(int argc, char *argv[]) memset(ctx, 0, sizeof(*ctx)); */ wait_for_open(ctx, dbstring); - if (edg_wll_DBCheckVersion(ctx, dbstring)) { + if ((ctx->dbcaps = glite_lbu_DBQueryCaps(ctx->dbctx)) == -1) + { char *et,*ed; - edg_wll_Error(ctx,&et,&ed); + glite_lbu_DBError(ctx->dbctx,&et,&ed); - fprintf(stderr,"%s: open database: %s (%s)\n",name,et,ed); + fprintf(stderr,"%s: open database: %s (%s)\n",argv[0],et,ed); + free(et); free(ed); return 1; } - if (!ctx->use_transactions && transactions != 0) { - fprintf(stderr, "%s: transactions aren't supported!\n", name); + edg_wll_Close(ctx); + ctx->dbctx = NULL; + fprintf(stderr, "[%d]: DB '%s'\n", getpid(), dbstring); + + if ((ctx->dbcaps & GLITE_LBU_DB_CAP_INDEX) == 0) { + fprintf(stderr,"%s: missing index support in DB layer\n",argv[0]); + return 1; } + if ((ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS) == 0) + fprintf(stderr, "[%d]: transactions aren't supported!\n", getpid()); if (transactions >= 0) { - fprintf(stderr, "%s: transactions forced from %d to %d\n", name, ctx->use_transactions, transactions); + fprintf(stderr, "[%d]: transactions forced from %d to %d\n", getpid(), ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS ? 1 : 0, transactions); + ctx->dbcaps &= ~GLITE_LBU_DB_CAP_TRANSACTIONS; + ctx->dbcaps |= transactions ? GLITE_LBU_DB_CAP_TRANSACTIONS : 0; } - edg_wll_Close(ctx); + use_dbcaps = ctx->dbcaps; edg_wll_FreeContext(ctx); if ( !debug ) { @@ -371,7 +383,8 @@ int clnt_data_init(void **data) dprintf(("[%d] opening database ...\n", getpid())); wait_for_open(ctx, dbstring); - cdata->mysql = ctx->mysql; + cdata->dbctx = ctx->dbctx; + cdata->dbcaps = use_dbcaps; edg_wll_FreeContext(ctx); #ifdef LB_PERF @@ -397,7 +410,8 @@ int handle_conn(int conn, struct timeval *timeout, void *data) /* Shared structures (pointers) */ - ctx->mysql = cdata->mysql; + ctx->dbctx = cdata->dbctx; + ctx->dbcaps = cdata->dbcaps; /* set globals */ @@ -588,7 +602,7 @@ static void wait_for_open(edg_wll_Context ctx, const char *dbstring) char *errt,*errd; if (dbfail_string1) free(dbfail_string1); - edg_wll_Error(ctx,&errt,&errd); + glite_lbu_DBError(ctx->dbctx,&errt,&errd); asprintf(&dbfail_string1,"%s (%s)\n",errt,errd); if (dbfail_string1 != NULL) { if (dbfail_string2 == NULL || strcmp(dbfail_string1,dbfail_string2)) { @@ -608,8 +622,6 @@ static void wait_for_open(edg_wll_Context ctx, const char *dbstring) dprintf(("[%d]: DB connection established\n",getpid())); if (!debug) syslog(LOG_INFO,"DB connection established\n"); } - - if (transactions >= 0) ctx->use_transactions = transactions; } static int decrement_timeout(struct timeval *timeout, struct timeval before, struct timeval after) diff --git a/org.glite.lb.server-bones/Makefile b/org.glite.lb.server-bones/Makefile index 9448405..b1c1731 100644 --- a/org.glite.lb.server-bones/Makefile +++ b/org.glite.lb.server-bones/Makefile @@ -2,7 +2,7 @@ top_srcdir=. stagedir=. globalprefix=glite -lbutilsprefix=lbu +lbprefix=lb package=glite-lb-server-bones version=0.0.1 PREFIX=/opt/glite @@ -65,12 +65,12 @@ cnt_example: cnt_example.o doc: install: - mkdir -p ${PREFIX}/include/${globalprefix}/${lbutilsprefix} + mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix} mkdir -p ${PREFIX}/lib ${INSTALL} -m 644 ${LTLIB} ${PREFIX}/lib if [ x${DOSTAGE} = xyes ]; then \ ${INSTALL} -m 644 ${STATICLIB} ${PREFIX}/lib ; \ - cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbutilsprefix} ; \ + cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix} ; \ fi clean: -- 1.8.2.3