From 97f090566059f876b787527e789f7a869eec5791 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Sun, 2 Apr 2006 09:33:11 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'glite-lb- common_branch_3_1_0_RC31'. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Sprout from glite-lb-common_branch_3_0_0_2_pre_cares 2005-10-18 15:36:28 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch 'glite-lb-' Cherrypick from master 2006-04-02 09:33:09 UTC Aleš Křenek 'push version': org.glite.lb.common/Makefile org.glite.lb.common/interface/context-int.h org.glite.lb.common/project/build.number org.glite.lb.common/project/configure.properties.xml org.glite.lb.common/project/version.properties org.glite.lb.common/src/context.c org.glite.lb.common/src/il_msg.c org.glite.lb.common/src/lb_plain_io.c org.glite.lb.common/src/log_msg.c org.glite.lb.common/src/ulm_parse.c --- org.glite.lb.common/Makefile | 29 +++++++++++--------- org.glite.lb.common/interface/context-int.h | 1 + org.glite.lb.common/project/build.number | 4 +-- .../project/configure.properties.xml | 4 ++- org.glite.lb.common/project/version.properties | 5 ++-- org.glite.lb.common/src/context.c | 31 +++++++++++++++++++--- org.glite.lb.common/src/il_msg.c | 18 ++++++++++++- org.glite.lb.common/src/lb_plain_io.c | 8 ++++++ org.glite.lb.common/src/log_msg.c | 11 +++++++- org.glite.lb.common/src/ulm_parse.c | 3 ++- 10 files changed, 89 insertions(+), 25 deletions(-) diff --git a/org.glite.lb.common/Makefile b/org.glite.lb.common/Makefile index 2d3ac3e..58fdde0 100644 --- a/org.glite.lb.common/Makefile +++ b/org.glite.lb.common/Makefile @@ -15,7 +15,6 @@ globus_prefix=/opt/globus nothrflavour=gcc32 thrflavour=gcc32pthr expat_prefix=/opt/expat -ares_prefix=/opt/ares -include Makefile.inc -include ../Makefile.inc @@ -37,7 +36,6 @@ CFLAGS:=${DEBUG} -I${top_srcdir}/src -I${top_srcdir}/interface \ -I${stagedir}/include \ -I${glite_location}/include \ -I${expat_prefix}/include \ - -I${ares_prefix}/include \ ${COVERAGE_FLAGS} \ -D_GNU_SOURCE \ -DDATAGRID_EXTENSION @@ -53,6 +51,10 @@ GLOBUS_LIBS:=-L${globus_prefix}/lib \ -lglobus_common_${nothrflavour} \ -lglobus_gssapi_gsi_${nothrflavour} \ +GLOBUS_THRLIBS:=-L${globus_prefix}/lib \ + -lglobus_common_${thrflavour} \ + -lglobus_gssapi_gsi_${thrflavour} \ + GLITE_LIBS:=-L${glite_location}/lib ifneq (${expat_prefix},/usr) @@ -60,17 +62,16 @@ ifneq (${expat_prefix},/usr) endif EXPAT_LIBS:=${EXPAT_LIBS} -lexpat -ARES_LIBS:=-L${ares_prefix}/lib -lares LDFLAGS:=-L${stagedir}/lib \ ${COVERAGE_FLAGS} -EXT_LIBS:= ${EXPAT_LIBS} ${ARES_LIBS} ${GLOBUS_LIBS} +EXT_LIBS:= ${EXPAT_LIBS} ${GLOBUS_LIBS} +EXT_THRLIBS:= ${EXPAT_LIBS} ${GLOBUS_THRLIBS} # breaks linking when not installed in /opt, /home/dimeglio etc. # ${GLITE_LIBS} \ # ${GLOBUS_LIBS} \ -# ${EXPAT_LIBS} \ -# ${ARES_LIBS} \ +# ${EXPAT_LIBS} TEST_LIBS:=-L${cppunit}/lib -lcppunit TEST_INC:=-I${cppunit}/include @@ -89,8 +90,8 @@ LOBJS:=${OBJS:.o=.lo} TRIO_OBJS:=escape.o trio.o strio.o TRIO_LIB:=libglite_lb_trio.a -MAILDIR_OBJS:=lb_maildir.o -MAILDIR_LIB:=libglite_lb_maildir.a +MAILDIR_OBJS:=lb_maildir.lo +MAILDIR_LIB:=libglite_lb_maildir.la THROBJS:=${OBJS:.o=.thr.o} THRLOBJS:=${OBJS:.o=.thr.lo} @@ -121,7 +122,10 @@ all compile: check_version ${STATICLIB} ${LTLIB} ${THRSTATICLIB} ${THRLTLIB} ${T # # version_info=-version-info `echo ${version} | cut -d. -f1,2 | tr . :` + +# counted minors: 1.1 offset=1 + version_info:=-version-info ${shell \ perl -e '$$,=":"; @F=split "\\.","${version}"; print $$F[0]+$$F[1]+${offset},$$F[2],$$F[1]' } @@ -134,8 +138,7 @@ ${TRIO_LIB}: ${TRIO_OBJS} ranlib $@ ${MAILDIR_LIB}: ${MAILDIR_OBJS} - ar crv $@ ${MAILDIR_OBJS} - ranlib $@ + ${LINK} ${version_info} -o $@ ${MAILDIR_OBJS} ${THRSTATICLIB}: ${THROBJS} ar crv $@ ${THROBJS} @@ -152,7 +155,7 @@ ${THRLTLIB}: ${THROBJS} ${LINK} ${version_info} -o $@ ${THRLOBJS} \ -lglite_security_gss_${thrflavour} \ -lglite_wmsutils_cjobid \ - ${EXT_LIBS} \ + ${EXT_THRLIBS} \ -lm stage: compile @@ -197,12 +200,12 @@ distbin: install: mkdir -p ${PREFIX}/lib mkdir -p ${PREFIX}/share/doc/${package}-${version} - ${INSTALL} -m 644 ${LTLIB} ${THRLTLIB} ${PREFIX}/lib + ${INSTALL} -m 644 ${LTLIB} ${THRLTLIB} ${MAILDIR_LIB} ${PREFIX}/lib ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} if [ x${DOSTAGE} = xyes ]; then \ mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix} ; \ (cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix}) ; \ - install -m 644 ${STATICLIB} ${THRSTATICLIB} ${TRIO_LIB} ${MAILDIR_LIB} ${PREFIX}/lib; \ + install -m 644 ${STATICLIB} ${THRSTATICLIB} ${TRIO_LIB} ${PREFIX}/lib; \ fi clean: diff --git a/org.glite.lb.common/interface/context-int.h b/org.glite.lb.common/interface/context-int.h index 9d68ded..84cbedf 100644 --- a/org.glite.lb.common/interface/context-int.h +++ b/org.glite.lb.common/interface/context-int.h @@ -16,6 +16,7 @@ typedef struct _edg_wll_SeqCode { unsigned int c[EDG_WLL_SOURCE__LAST]; } edg_wll_SeqCode; +#define EDG_WLL_SEQ_NULL "UI=000000:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000" /* non-gsi one-element analogy of connPool for L&B Proxy server */ diff --git a/org.glite.lb.common/project/build.number b/org.glite.lb.common/project/build.number index 8b2682f..4e13dcd 100644 --- a/org.glite.lb.common/project/build.number +++ b/org.glite.lb.common/project/build.number @@ -1,2 +1,2 @@ -#Sun Oct 16 20:21:47 CEST 2005 -module.build=154 +#Sun Apr 02 07:07:33 CEST 2006 +module.build=0241 diff --git a/org.glite.lb.common/project/configure.properties.xml b/org.glite.lb.common/project/configure.properties.xml index 911dfcf..979c6f1 100644 --- a/org.glite.lb.common/project/configure.properties.xml +++ b/org.glite.lb.common/project/configure.properties.xml @@ -20,6 +20,9 @@ Revision history: $Log$ + Revision 1.3 2004/08/31 07:57:17 akrenek + very first unit test + Revision 1.2 2004/07/06 20:50:10 flammer Moved to configure.properties.xml @@ -48,7 +51,6 @@ version=${module.version} glite_location=${with.glite.location} globus_prefix=${with.globus.prefix} expat_prefix=${with.expat.prefix} -ares_prefix=${with.ares.prefix} thrflavour=${with.globus.thr.flavor} nothrflavour=${with.globus.nothr.flavor} cppunit=${with.cppunit.prefix} diff --git a/org.glite.lb.common/project/version.properties b/org.glite.lb.common/project/version.properties index 2d55ba2..6ce0f36 100644 --- a/org.glite.lb.common/project/version.properties +++ b/org.glite.lb.common/project/version.properties @@ -1,4 +1,3 @@ #Fri Sep 02 14:17:07 CEST 2005 -module.version=3.0.0 -module.build=2 -module.age=1 +module.version=3.1.0 +module.age=0 diff --git a/org.glite.lb.common/src/context.c b/org.glite.lb.common/src/context.c index 7978a9e..561e068 100644 --- a/org.glite.lb.common/src/context.c +++ b/org.glite.lb.common/src/context.c @@ -15,6 +15,10 @@ static void free_voms_groups(edg_wll_VomsGroups *); +/* uncomment to get the trace +#define CTXTRACE "/tmp/lb-context-trace" +*/ + int edg_wll_InitContext(edg_wll_Context *ctx) { int i; @@ -32,11 +36,23 @@ int edg_wll_InitContext(edg_wll_Context *ctx) out->connPool = (edg_wll_ConnPool *) calloc(out->poolSize, sizeof(edg_wll_ConnPool)); out->connPoolNotif = (edg_wll_ConnPool *) calloc(1, sizeof(edg_wll_ConnPool)); - out->connProxy = (edg_wll_ConnPool *) calloc(1, sizeof(edg_wll_ConnProxy)); + out->connProxy = (edg_wll_ConnProxy *) calloc(1, sizeof(edg_wll_ConnProxy)); out->connProxy->conn.sock = -1; out->connToUse = -1; *ctx = out; + +#ifdef CTXTRACE +{ + int trc = open(CTXTRACE,O_WRONLY|O_CREAT,0644); + char buf[200]; + sprintf(buf,"%p init\n",out); + lseek(trc,0,SEEK_END); + write(trc,buf,strlen(buf)); + close(trc); +} +#endif + return 0; } @@ -46,7 +62,16 @@ void edg_wll_FreeContext(edg_wll_Context ctx) OM_uint32 min_stat; if (!ctx) return; - +#ifdef CTXTRACE +{ + int trc = open(CTXTRACE,O_WRONLY|O_CREAT,0644); + char buf[200]; + sprintf(buf,"%p free\n",ctx); + lseek(trc,0,SEEK_END); + write(trc,buf,strlen(buf)); + close(trc); +} +#endif if (ctx->errDesc) free(ctx->errDesc); if (ctx->connPool) { int i; @@ -103,7 +128,7 @@ static const char* const errTexts[] = { "DNS resolver error", "No JobId specified in context", "No indexed condition in query", - "Interlogger protocol error", + "Lbserver (proxy) store protocol error", "Interlogger internal error", "Interlogger has events pending", "Compared events differ", diff --git a/org.glite.lb.common/src/il_msg.c b/org.glite.lb.common/src/il_msg.c index 10f7a82..4154ee9 100644 --- a/org.glite.lb.common/src/il_msg.c +++ b/org.glite.lb.common/src/il_msg.c @@ -109,7 +109,7 @@ read_il_data(void *user_data, char **buffer, int (*reader)(void *, char *, const int)) { - char buf[17]; + char buf[17], *p; int ret, len; /* read 17 byte header */ @@ -117,7 +117,23 @@ read_il_data(void *user_data, if(len < 0) { goto err; } + + /* perform some sanity checks on the received header */ + if(buf[16] != '\n') { + len = -1; + goto err; + } buf[16] = 0; + /* skip leading spaces */ + for(p = buf; *p == ' '; p++); + /* skip digits */ + for(; (*p >= '0') && (*p <= '9'); p++); + /* this must be the end of string */ + if(*p != 0) { + len = -1; + goto err; + } + if((len=atoi(buf)) <= 0) { len = -1; goto err; diff --git a/org.glite.lb.common/src/lb_plain_io.c b/org.glite.lb.common/src/lb_plain_io.c index 92bbf2b..7915dfa 100644 --- a/org.glite.lb.common/src/lb_plain_io.c +++ b/org.glite.lb.common/src/lb_plain_io.c @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include #include #include @@ -173,7 +175,11 @@ int edg_wll_plain_write_full( int ct = -1; fd_set fds; struct timeval timeout, before, after; + struct sigaction sa,osa; + memset(&sa,0,sizeof(sa)); assert(sa.sa_handler == NULL); + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE,&sa,&osa); if ( to ) { memcpy(&timeout, to, sizeof(timeout)); @@ -204,5 +210,7 @@ end: if (to->tv_sec < 0) to->tv_sec = to->tv_usec = 0; } + sigaction(SIGPIPE,&osa,NULL); + if (errno == EPIPE) errno = ENOTCONN; return (errno)? -1: written; } diff --git a/org.glite.lb.common/src/log_msg.c b/org.glite.lb.common/src/log_msg.c index befa8cd..595ed19 100644 --- a/org.glite.lb.common/src/log_msg.c +++ b/org.glite.lb.common/src/log_msg.c @@ -1,3 +1,8 @@ +#include +#include +#include +#include +#include #include #include #include @@ -138,7 +143,7 @@ int edg_wll_log_event_write( case EAGAIN: case EACCES: case EINTR: - sleep(fcntl_timeout); + if ((i+1) < fcntl_attempts) sleep(fcntl_timeout); break; default: edg_wll_SetError(ctx, errno, "fcntl()"); @@ -146,6 +151,10 @@ int edg_wll_log_event_write( } } else break; } + if (i == fcntl_attempts) { + edg_wll_SetError(ctx, ETIMEDOUT, "timed out trying to lock event file"); + goto cleanup; + } if ( fseek(outfile, 0, SEEK_END) == -1 ) { edg_wll_SetError(ctx, errno, "fseek()"); diff --git a/org.glite.lb.common/src/ulm_parse.c b/org.glite.lb.common/src/ulm_parse.c index 2525a3e..855c26b 100644 --- a/org.glite.lb.common/src/ulm_parse.c +++ b/org.glite.lb.common/src/ulm_parse.c @@ -384,13 +384,14 @@ void edg_wll_ULMSplitDate( const char *s, int edg_wll_ULMTimevalToDate( long sec, long usec, char *dstr ) { char *func = "edg_wll_ULMTimevalToDate"; + struct tm tms; struct tm *tp; int len; if ( sec < 0 || usec < 0 || usec > 999999 ) return 1; - tp = gmtime( (const time_t *) &sec ); + tp = gmtime_r( (const time_t *) &sec, &tms ); if ( tp == NULL ) return 1; -- 1.8.2.3