From ba958fab5d539bc988b146e312a4bf8a3eb2e801 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Tue, 19 Sep 2006 20:28:45 +0000 Subject: [PATCH] Builds after merge _RC31 --- org.glite.lb.client-interface/interface/notifid.h | 8 + .../project/version.properties | 2 +- org.glite.lb.client/Makefile | 29 +- org.glite.lb.client/examples/dagids.c | 61 ++++ org.glite.lb.client/examples/flood_proxy.c | 77 +++++ org.glite.lb.client/examples/job_reg.c | 11 +- org.glite.lb.client/examples/lbmon.c | 137 +++++++++ org.glite.lb.client/examples/stress_context.c | 110 +++++++ org.glite.lb.client/examples/ulmfields.pl | 31 ++ .../project/configure.properties.xml | 11 +- org.glite.lb.client/project/version.properties | 2 +- org.glite.lb.client/src/connection.c | 49 +++- org.glite.lb.client/src/connection.h | 4 +- org.glite.lb.client/{examples => src}/export.sh | 34 ++- org.glite.lb.client/src/lb_dump_exporter.c | 10 +- org.glite.lb.client/src/notification.c | 17 +- org.glite.lb.client/src/perftest_logjobs.c | 2 +- org.glite.lb.client/src/producer.c | 64 +++- org.glite.lb.client/test/producer_test.cpp | 4 +- org.glite.lb.common/interface/lb_maildir.h | 2 +- org.glite.lb.common/interface/log_proto.h | 2 +- org.glite.lb.common/project/version.properties | 2 +- org.glite.lb.common/src/lb_maildir.c | 90 +++--- org.glite.lb.common/src/lb_plain_io.c | 38 ++- org.glite.lb.common/src/mini_http.c | 1 + org.glite.lb.common/src/notifid.c | 17 ++ .../config/glite-lb-logger.default-properties | 4 +- org.glite.lb.logger/config/startup | 2 + org.glite.lb.logger/project/version.properties | 2 +- org.glite.lb.logger/src/interlogd.c | 3 +- org.glite.lb.logger/src/logd.c | 3 +- org.glite.lb.logger/src/send_event.c | 11 +- .../project/version.properties | 2 +- org.glite.lb.server-bones/src/srvbones.c | 7 +- org.glite.lb.server/Makefile | 2 +- org.glite.lb.server/interface/job-attrs.xsd | 23 +- org.glite.lb.server/interface/job-record.xsd | 4 + org.glite.lb.server/project/version.properties | 2 +- org.glite.lb.server/src/bkserverd.c | 4 +- org.glite.lb.server/src/il_lbproxy.c | 2 +- org.glite.lb.server/src/il_notification.c | 2 +- org.glite.lb.server/src/lb_plugin.c | 245 ++++++++++++---- org.glite.lb.server/src/process_event.c | 2 +- org.glite.lb.server/src/srv_purge.c | 2 +- org.glite.lb.utils/project/version.properties | 2 +- org.glite.lb.utils/src/lb_statistics.c | 321 +++++++++++++++++++++ org.glite.lb.utils/src/statistics.c | 164 ++++++----- .../project/version.properties | 2 +- org.glite.lb/project/dependencies.properties | 22 +- org.glite.lb/project/version.properties | 2 +- 50 files changed, 1354 insertions(+), 296 deletions(-) create mode 100644 org.glite.lb.client/examples/dagids.c create mode 100644 org.glite.lb.client/examples/flood_proxy.c create mode 100644 org.glite.lb.client/examples/lbmon.c create mode 100644 org.glite.lb.client/examples/stress_context.c create mode 100644 org.glite.lb.client/examples/ulmfields.pl rename org.glite.lb.client/{examples => src}/export.sh (56%) create mode 100644 org.glite.lb.utils/src/lb_statistics.c diff --git a/org.glite.lb.client-interface/interface/notifid.h b/org.glite.lb.client-interface/interface/notifid.h index 3ef1054..1a78c1b 100644 --- a/org.glite.lb.client-interface/interface/notifid.h +++ b/org.glite.lb.client-interface/interface/notifid.h @@ -77,6 +77,14 @@ char *edg_wll_NotifIdGetUnique(const edg_wll_NotifId notifid); */ int edg_wll_NotifIdSetUnique(edg_wll_NotifId *notifid, const char *unique); +/** + * Duplicate a NotifId + * \param[in] src a notifid to duplicate + * \retval pointer to allocated memory containg the duplicated notifid + * \retval NULL if memory allocation fails or notifid is invalid + */ +edg_wll_NotifId *edg_wll_NotifIdDup(const edg_wll_NotifId src); + /* *@} end of group */ diff --git a/org.glite.lb.client-interface/project/version.properties b/org.glite.lb.client-interface/project/version.properties index 348eaf7..1faf38d 100644 --- a/org.glite.lb.client-interface/project/version.properties +++ b/org.glite.lb.client-interface/project/version.properties @@ -1,4 +1,4 @@ #Fri Sep 02 14:16:31 CEST 2005 # glite-lb-client-interface_branch_3_0_0_RC15 tag is taken! -module.version=2.3.0 +module.version=2.2.1 module.age=0 diff --git a/org.glite.lb.client/Makefile b/org.glite.lb.client/Makefile index 1b89a22..69601b2 100644 --- a/org.glite.lb.client/Makefile +++ b/org.glite.lb.client/Makefile @@ -14,7 +14,6 @@ glite_location=/opt/glite globus_prefix=/opt/globus nothrflavour=gcc32 thrflavour=gcc32pthr -expat_prefix=/opt/expat CC:=gcc CXX:=g++ @@ -82,28 +81,12 @@ CFLAGS:=${DEBUG} \ -I${top_srcdir}/src -I${top_srcdir}/interface \ -I${stagedir}/include \ -I${glite_location}/include \ - -I${expat_prefix}/include \ - -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql \ ${COVERAGE_FLAGS} \ -D_GNU_SOURCE ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} CXXFLAGS:=${CFLAGS} -ifneq (${mysql_prefix},/usr) - ifeq ($(shell echo ${mysql_version} | cut -d. -f1,2),4.1) - mysqlib := -L${mysql_prefix}/lib/mysql - else - mysqlib := -L${mysql_prefix}/lib - endif -endif - -ifneq (${expat_prefix},/usr) - EXPAT_LIBS:=-L${expat_prefix}/lib -endif -EXPAT_LIBS := ${EXPAT_LIBS} -lexpat - -EXT_LIB:= ${mysqlib} -lmysqlclient -lz\ - ${EXPAT_LIBS} +EXT_LIB:= TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit TEST_INC:=-I${cppunit_prefix}/include @@ -148,8 +131,9 @@ THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la TOOLS:=dump load purge lb_dump_exporter ${LB_PERF_TOOLS} EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl stresslog +EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl stresslog lbmon flood_proxy dagids stress_context -EXAMPLES_CL=user_jobs job_status +EXAMPLES_CL=user_jobs job_status FAKE_EXAMPLES:=job_log_fake MAN_GZ:=glite-lb-logevent.1.gz @@ -254,7 +238,7 @@ default: all ifdef LB_STANDALONE compile all: ${LIB} ${THRLIB} ${TOOLS} logevent examples ${MAN_GZ} else -compile all: ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} examples ${MAN_GZ} +compile all: check_version ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} examples ${MAN_GZ} endif examples: ${EXAMPLES} ${EXAMPLES_CL} ${sh_PROGS} @@ -305,7 +289,7 @@ endif ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} ${INSTALL} -m 644 ${top_srcdir}/doc/README-fake ${top_srcdir}/doc/README-notify ${PREFIX}/share/doc/${package}-${version} mkdir -p ${PREFIX}/examples - for p in logevent ; do \ + for p in logevent; do \ ${INSTALL} -m 755 "$$p" "${PREFIX}/bin/glite-lb-$$p"; \ done for p in ${TOOLS} ; do \ @@ -314,8 +298,7 @@ endif for p in ${EXAMPLES} ${EXAMPLES_CL} ${sh_PROGS} ; do \ ${INSTALL} -m 755 "$$p" "${PREFIX}/examples/glite-lb-$$p"; \ done - ${INSTALL} -m 755 ${top_srcdir}/examples/export.sh "${PREFIX}/examples/glite-lb-export.sh" -# ${INSTALL} -m 755 ${top_srcdir}/examples/log_dag.sh "${PREFIX}/examples/glite-lb-log_dag.sh" + ${INSTALL} -m 755 ${top_srcdir}/src/export.sh "${PREFIX}/sbin/glite-lb-export.sh" ${INSTALL} -m 644 ${MAN_GZ} ${PREFIX}/share/man/man1 clean: diff --git a/org.glite.lb.client/examples/dagids.c b/org.glite.lb.client/examples/dagids.c new file mode 100644 index 0000000..d45b90f --- /dev/null +++ b/org.glite.lb.client/examples/dagids.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include +#include + +#include "glite/wmsutils/jobid/cjobid.h" +#include "glite/lb/producer.h" +#include "glite/lb/events.h" + +extern char *optarg; +extern int opterr,optind; + +static void usage(char *me) +{ + fprintf(stderr,"usage: %s -m bkserver -n num_subjobs [-s seed]\n", me); +} + +int main(int argc, char *argv[]) +{ + char *seed = "seed", *server = NULL,*p; + int done = 0,num_subjobs = 0,i; + edg_wll_Context ctx; + edg_wlc_JobId jobid,*subjobs; + + + edg_wll_InitContext(&ctx); + opterr = 0; + + do { + switch (getopt(argc,argv,"m:n:s:")) { + case 's': seed = strdup(optarg); break; + case 'm': server = strdup(optarg); break; + case 'n': num_subjobs = atoi(optarg); break; + case '?': usage(argv[0]); exit(EINVAL); + case -1: done = 1; break; + } + } while (!done); + + if (!server) { + fprintf(stderr,"%s: -m server required\n",argv[0]); + exit(1); + } + + if (!num_subjobs) { + fprintf(stderr,"%s: -n num_subjobs required\n",argv[0]); + exit(1); + } + + p = strchr(server,':'); + if (p) *p=0; + edg_wlc_JobIdCreate(server,p?atoi(p+1):0,&jobid); + printf("seed=\"%s\"\nnodes=%d\ndag=\"%s\"\n",seed,num_subjobs,edg_wlc_JobIdUnparse(jobid)); + + edg_wll_GenerateSubjobIds(ctx,jobid,num_subjobs,seed,&subjobs); + + for (i=0; i +#include +#include +#include +#include +#include +#include +#include + +#include "glite/lb/producer.h" +#include "glite/wmsutils/jobid/cjobid.h" + +static void slave(); + +int main(int argc,char **argv) +{ + int i,nproc; + + if (argc != 2) { + fprintf(stderr,"usage: %s nproc\n",argv[0]); + return 1; + } + + nproc = atoi(argv[1]); + if (nproc < 1) { + fprintf(stderr,"%s: nproc must be >= 1\n",argv[0]); + return 1; + } + + for (i=0; i0) { reg_subjobs = 1; break; } case 'l': jdl = (char *) strdup(optarg); break; + case 'e': seed = strdup(optarg); break; case '?': usage(argv[0]); exit(EINVAL); case -1: done = 1; break; } @@ -88,7 +89,7 @@ int main(int argc, char *argv[]) if (edg_wll_RegisterJobProxy(ctx,jobid, num_subjobs?EDG_WLL_REGJOB_DAG:EDG_WLL_REGJOB_SIMPLE, jdl ? jdl : "blabla", "NNNSSSS", - num_subjobs,NULL,&subjobs)) + num_subjobs,seed,&subjobs)) { char *et,*ed; edg_wll_Error(ctx,&et,&ed); @@ -99,7 +100,7 @@ int main(int argc, char *argv[]) if (edg_wll_RegisterJobSync(ctx,jobid, num_subjobs?EDG_WLL_REGJOB_DAG:EDG_WLL_REGJOB_SIMPLE, jdl ? jdl : "blabla", "NNNSSSS", - num_subjobs,NULL,&subjobs)) + num_subjobs,seed,&subjobs)) { char *et,*ed; edg_wll_Error(ctx,&et,&ed); diff --git a/org.glite.lb.client/examples/lbmon.c b/org.glite.lb.client/examples/lbmon.c new file mode 100644 index 0000000..2d466b9 --- /dev/null +++ b/org.glite.lb.client/examples/lbmon.c @@ -0,0 +1,137 @@ +#ident "$Header$" + +#include +#include +#include +#include +#include +#include + +#include "glite/lb/consumer.h" + +static void usage(char *); +static int query_all(edg_wll_Context, int, struct timeval, edg_wll_JobStat **, edg_wlc_JobId **); +static void dgerr(edg_wll_Context,char *); + +static char *myname = NULL; +static int debug = 0, verbose = 0, lbproxy =0; +static const char rcsid[] = "@(#)$Id$"; + +static struct option const long_options[] = { + { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'V' }, + { "verbose", no_argument, 0, 'v' }, + { "debug", no_argument, 0, 'd' }, + { "lbproxy", required_argument, 0, 'x' }, + { NULL, 0, NULL, 0} +}; + +int main(int argc,char *argv[]) { + edg_wll_Context ctx; + edg_wll_JobStat *statesOut = NULL; + edg_wlc_JobId *jobsOut = NULL; + struct timeval time_now; + + int i, result, opt, nJobs; + i = result = opt = 0; + gettimeofday(&time_now,0); + + myname = argv[0]; + fprintf(stdout,"\n"); + /* get arguments */ + while ((opt = getopt_long(argc,argv, + "h" /* help */ + "V" /* version */ + "v" /* verbose */ + "d" /* debug */ + "x", /* lbproxy */ + long_options, (int *) 0)) != EOF) { + + switch (opt) { + case 'V': fprintf(stdout,"%s:\t%s\n",argv[0],rcsid); exit(0); + case 'v': verbose = 1; break; + case 'd': debug = 1; break; + case 'x': lbproxy = 1; break; + case 'h': + default: + usage(argv[0]); exit(0); + } + } + if ( edg_wll_InitContext(&ctx) ) { + fprintf(stderr,"%s: cannot initialize edg_wll_Context\n ",myname); + exit(1); + } + + if ( (result = query_all(ctx, EDG_WLL_JOB_CLEARED, time_now, &statesOut, &jobsOut)) ) { + dgerr(ctx, "edg_wll_QueryJobs"); + } else { + fprintf(stdout,"Number of jobs... "); + } + + nJobs = 0; + if ( jobsOut ) { + for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]); { + nJobs++; + free(jobsOut); + } + } + if ( statesOut ) { + for (i=0; statesOut[i].state; i++) edg_wll_FreeStatus(&statesOut[i]); + free(statesOut); + } + edg_wll_FreeContext(ctx); + + + return result; +} + +static void +usage(char *name) { + fprintf(stderr,"Usage: %s [-x]\n", name); +} + +static int +query_all(edg_wll_Context ctx, int query_status, struct timeval query_time, edg_wll_JobStat **statesOut, edg_wlc_JobId **jobsOut) { + edg_wll_QueryRec jc[3]; + int ret; + + memset(jc, 0, sizeof jc); + + /* jobs in the state 'query_status' within last hour */ + jc[0].attr = EDG_WLL_QUERY_ATTR_STATUS; + jc[0].op = EDG_WLL_QUERY_OP_EQUAL; + jc[0].value.i = query_status; + jc[1].attr = EDG_WLL_QUERY_ATTR_TIME; + jc[1].attr_id.state = query_status; + jc[1].op = EDG_WLL_QUERY_OP_WITHIN; + jc[1].value.t.tv_sec = query_time.tv_sec - 3600; + jc[1].value.t.tv_usec = query_time.tv_usec; + jc[1].value2.t.tv_sec = query_time.tv_sec; + jc[1].value2.t.tv_usec = query_time.tv_usec; + jc[2].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + if ( (ret = edg_wll_QueryJobs(ctx, jc, 0, jobsOut, statesOut)) ) { + if ( ret == E2BIG ) { + int r; + if ( edg_wll_GetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, &r) ) return ret; + if ( r != EDG_WLL_QUERYRES_LIMITED ) return ret; + + fprintf(stderr," edg_wll_QueryJobs() Warning: only limited result returned!\n"); + return 0; + } else return ret; + } + + return ret; +} + +static void +dgerr(edg_wll_Context ctx,char *where) { + char *etxt,*edsc; + + edg_wll_Error(ctx,&etxt,&edsc); + fprintf(stderr,"%s: %s: %s",myname,where,etxt); + if (edsc) fprintf(stderr," (%s)",edsc); + putc('\n',stderr); + if(etxt) free(etxt); + if(edsc) free(edsc); +} diff --git a/org.glite.lb.client/examples/stress_context.c b/org.glite.lb.client/examples/stress_context.c new file mode 100644 index 0000000..405f4d1 --- /dev/null +++ b/org.glite.lb.client/examples/stress_context.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include + +#include "glite/wmsutils/jobid/cjobid.h" +#include "glite/lb/producer.h" +#include "glite/lb/events.h" + +char *outfile = "context_errors"; +edg_wlc_JobId job; + +static int stop; + +struct { + int err; + char *text,*desc; +} *errors; + +int nerrors; + +static void killslaves(int sig) +{ + kill(0,SIGTERM); + exit(0); +} + +static void terminate(int sig) +{ + stop = sig; +} + +static void slave(int num) +{ + int good = 0,i; + char fname[PATH_MAX]; + FILE *errf; + edg_wll_Context ctx; + + signal(SIGINT,terminate); + signal(SIGTERM,terminate); + signal(SIGHUP,terminate); + + + while (!stop) { + edg_wll_InitContext(&ctx); + edg_wll_SetParam(ctx, EDG_WLL_PARAM_SOURCE, EDG_WLL_SOURCE_WORKLOAD_MANAGER); + + if (edg_wll_SetLoggingJobProxy(ctx,job,NULL,"/I/am/the/user",EDG_WLL_SEQ_NORMAL) && !stop) { + errors = realloc(errors,(nerrors+1) * sizeof(*errors)); + errors[nerrors].err = edg_wll_Error(ctx,&errors[nerrors].text,&errors[nerrors].desc); + nerrors++; + } + else good++; + + edg_wll_FreeContext(ctx); + } + + sprintf(fname,"%s_%03d",outfile,num); + errf = fopen(fname,"w"); + if (!errf) { perror(fname); exit(1); } + + for (i=0; i>>>>>> 1.5.2.1 Revision 1.5 2006/03/15 18:02:37 akrenek cares @@ -31,7 +40,7 @@ Revision 1.3 2004/08/31 16:32:31 jpospi First attempt to producer test - + Revision 1.2 2004/07/06 20:47:11 flammer Moved to configure.properties.xml diff --git a/org.glite.lb.client/project/version.properties b/org.glite.lb.client/project/version.properties index 80879a1..c4facf2 100644 --- a/org.glite.lb.client/project/version.properties +++ b/org.glite.lb.client/project/version.properties @@ -1,4 +1,4 @@ #Fri Sep 02 14:17:41 CEST 2005 # glite-lb-client_branch_3_0_0_RC15 tag is taken! -module.version=2.3.0 +module.version=2.2.3 module.age=0 diff --git a/org.glite.lb.client/src/connection.c b/org.glite.lb.client/src/connection.c index 232be5b..4230b07 100644 --- a/org.glite.lb.client/src/connection.c +++ b/org.glite.lb.client/src/connection.c @@ -17,7 +17,7 @@ #include "glite/lb/context-int.h" #include "glite/lb/mini_http.h" - +#include "connection.h" static void CloseConnection(edg_wll_Context ctx, int conn_index) { @@ -116,7 +116,7 @@ int edg_wll_close_proxy(edg_wll_Context ctx) { edg_wll_plain_close(&ctx->connProxy->conn); - return edg_wll_Error(ctx, NULL, NULL); + return edg_wll_ResetError(ctx); } @@ -202,7 +202,13 @@ int edg_wll_open_proxy(edg_wll_Context ctx) { struct sockaddr_un saddr; int flags; - + int err; + char *ed = NULL; + int retries = 0; + + edg_wll_ResetError(ctx); + + edg_wll_ResetError(ctx); if (ctx->connProxy->conn.sock > -1) { // XXX: test path socket here? @@ -234,19 +240,48 @@ int edg_wll_open_proxy(edg_wll_Context ctx) goto err; } - if (connect(ctx->connProxy->conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - edg_wll_SetError(ctx, errno, "connect()"); + while ((err = connect(ctx->connProxy->conn.sock, (struct sockaddr *)&saddr, sizeof(saddr))) < 0 && + errno == EAGAIN && + ctx->p_tmp_timeout.tv_sec >= 0 && ctx->p_tmp_timeout.tv_usec >= 0 && + !(ctx->p_tmp_timeout.tv_sec == 0 && ctx->p_tmp_timeout.tv_usec == 0) + ) + { + struct timespec ns = { 0, PROXY_CONNECT_RETRY * 1000000 /* 10 ms */ },rem; + + nanosleep(&ns,&rem); + + ctx->p_tmp_timeout.tv_usec -= ns.tv_nsec/1000; + ctx->p_tmp_timeout.tv_usec += rem.tv_nsec/1000; + + ctx->p_tmp_timeout.tv_sec -= ns.tv_sec; + ctx->p_tmp_timeout.tv_sec += rem.tv_sec; + + if (ctx->p_tmp_timeout.tv_usec < 0) { + ctx->p_tmp_timeout.tv_usec += 1000000; + ctx->p_tmp_timeout.tv_sec--; + } + retries++; + } + + /* printf("retries %d\n",retries); */ + + if (err) { + if (errno == EAGAIN) edg_wll_SetError(ctx,ETIMEDOUT, "edg_wll_open_proxy()"); + else edg_wll_SetError(ctx, errno, "connect()"); goto err; } - return edg_wll_Error(ctx,NULL,NULL); + return 0; err: /* some error occured; close created connection */ + err = edg_wll_Error(ctx,NULL,&ed); edg_wll_close_proxy(ctx); + edg_wll_SetError(ctx,err,ed); + free(ed); - return edg_wll_Error(ctx,NULL,NULL); + return err; } diff --git a/org.glite.lb.client/src/connection.h b/org.glite.lb.client/src/connection.h index 7de349d..1b12058 100644 --- a/org.glite.lb.client/src/connection.h +++ b/org.glite.lb.client/src/connection.h @@ -1,7 +1,7 @@ #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ #define __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ -#ident "$Header" +#ident "$Header$" int edg_wll_close(edg_wll_Context ctx); int edg_wll_open(edg_wll_Context ctx); @@ -13,5 +13,7 @@ int edg_wll_http_send_recv_proxy(edg_wll_Context, char *, const char * const *, int http_check_status(edg_wll_Context, char *); +#define PROXY_CONNECT_RETRY 10 /* ms */ + #endif /* __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ */ diff --git a/org.glite.lb.client/examples/export.sh b/org.glite.lb.client/src/export.sh similarity index 56% rename from org.glite.lb.client/examples/export.sh rename to org.glite.lb.client/src/export.sh index 0d00941..eda817c 100644 --- a/org.glite.lb.client/examples/export.sh +++ b/org.glite.lb.client/src/export.sh @@ -30,29 +30,45 @@ fi # dump directory of bkserver +GLITE_LB_EXPORT_PURGEDIR=${GLITE_LB_EXPORT_PURGEDIR:-/tmp/purge} GLITE_LB_EXPORT_DUMPDIR=${GLITE_LB_EXPORT_DUMPDIR:-/tmp/dump} -GLITE_LB_EXPORT_DUMPDIR_OLD=${GLITE_LB_EXPORT_DUMPDIR_OLD:-$GLITE_LB_EXPORT_DUMPDIR.old} +GLITE_LB_EXPORT_PURGEDIR_KEEP=${GLITE_LB_EXPORT_PURGEDIR_KEEP:-""} +GLITE_LB_EXPORT_DUMPDIR_KEEP=${GLITE_LB_EXPORT_DUMPDIR_KEEP:-""} # maildir dump directory for jp importer GLITE_LB_EXPORT_JPDUMP_MAILDIR=${GLITE_LB_EXPORT_JPDUMP_MAILDIR:-/tmp/jpdump} # directory with exported data (file per job) -GLITE_LB_EXPORT_EXPORTDIR=${GLITE_LB_EXPORT_EXPORTDIR:-/tmp/lbexport} +GLITE_LB_EXPORT_JOBSDIR=${GLITE_LB_EXPORT_JOBSDIR:-/tmp/lbexport} # purge args (timeouts) -GLITE_LB_EXPORT_PURGE_ARGS=${GLITE_LB_EXPORT_PURGE_ARGS:--a 1h -c 1h -n 1h -o 1d} +GLITE_LB_EXPORT_PURGE_ARGS=${GLITE_LB_EXPORT_PURGE_ARGS:---cleared 2d --aborted 2w --cancelled 2w --other 2m} # Book Keeping Server -GLITE_LB_EXPORT_BKSERVER=${GLITE_LB_EXPORT_BKSERVER:-localhost:9000} +GLITE_LB_SERVER_PORT=${GLITE_LB_SERVER_PORT:-9000} +GLITE_LB_EXPORT_BKSERVER=${GLITE_LB_EXPORT_BKSERVER:-localhost:$GLITE_LB_SERVER_PORT} [ -d $GLITE_LB_EXPORT_JPDUMP_MAILDIR ] || mkdir -p $GLITE_LB_EXPORT_JPDUMP_MAILDIR [ -d $GLITE_LB_EXPORT_DUMPDIR ] || mkdir -p $GLITE_LB_EXPORT_DUMPDIR -[ -d $GLITE_LB_EXPORT_DUMPDIR_OLD ] || mkdir -p $GLITE_LB_EXPORT_DUMPDIR_OLD -[ -d $GLITE_LB_EXPORT_EXPORTDIR ] || mkdir -p $GLITE_LB_EXPORT_EXPORTDIR +[ -d $GLITE_LB_EXPORT_PURGEDIR ] || mkdir -p $GLITE_LB_EXPORT_PURGEDIR +[ -d $GLITE_LB_EXPORT_DUMPDIR_KEEP ] || mkdir -p $GLITE_LB_EXPORT_DUMPDIR_KEEP +[ -d $GLITE_LB_EXPORT_PURGEDIR_KEEP ] || mkdir -p $GLITE_LB_EXPORT_PURGEDIR_KEEP +[ -d $GLITE_LB_EXPORT_JOBSDIR ] || mkdir -p $GLITE_LB_EXPORT_JOBSDIR X509_USER_CERT="$X509_USER_CERT" X509_USER_KEY="$X509_USER_KEY" $PREFIX/sbin/glite-lb-purge $GLITE_LB_EXPORT_PURGE_ARGS -l -m $GLITE_LB_EXPORT_BKSERVER -for file in $GLITE_LB_EXPORT_DUMPDIR/*; do +for file in $GLITE_LB_EXPORT_PURGEDIR/*; do if [ -s $file ]; then - $PREFIX/sbin/glite-lb-lb_dump_exporter -d $file -s $GLITE_LB_EXPORT_EXPORTDIR -m $GLITE_LB_EXPORT_JPDUMP_MAILDIR - mv $file $GLITE_LB_EXPORT_DUMPDIR_OLD + $PREFIX/sbin/glite-lb-lb_dump_exporter -d $file -s $GLITE_LB_EXPORT_JOBSDIR -m $GLITE_LB_EXPORT_JPDUMP_MAILDIR + if [ -n "$GLITE_LB_EXPORT_PURGEDIR_KEEP" ]; then + mv $file $GLITE_LB_EXPORT_PURGEDIR_KEEP + else + rm $file + fi else rm $file fi done + +if [ -n "$GLITE_LB_EXPORT_DUMPDIR_KEEP" ]; then + ls $GLITE_LB_EXPORT_DUMPDIR | xargs -i'{}' cp $GLITE_LB_EXPORT_DUMPDIR/'{}' $GLITE_LB_EXPORT_DUMPDIR_KEEP; +else + ls $GLITE_LB_EXPORT_DUMPDIR | xargs -i'{}' rm -f $GLITE_LB_EXPORT_DUMPDIR/'{}' +fi + diff --git a/org.glite.lb.client/src/lb_dump_exporter.c b/org.glite.lb.client/src/lb_dump_exporter.c index 2eb1850..97a63ab 100644 --- a/org.glite.lb.client/src/lb_dump_exporter.c +++ b/org.glite.lb.client/src/lb_dump_exporter.c @@ -9,6 +9,8 @@ #include #include #include +#include + #include "glite/lb/context.h" #include "glite/lb/events.h" @@ -149,8 +151,9 @@ int main(int argc, char **argv) } if ( !(st = dump_storage_find(dstorage, jobid)) ) { - int fd, i; + int fd, i; char fname[PATH_MAX]; + struct timeval tv; i = 0; while ( 1 ) { @@ -159,9 +162,10 @@ int main(int argc, char **argv) perror("Can't create dump file - max tries limit reached "); cleanup(1); } - snprintf(fname, PATH_MAX, "%s/%s.%ld", store_pref, unique, (long) time(NULL)); + gettimeofday(&tv, NULL); + snprintf(fname, PATH_MAX, "%s/%s.%ld_%ld", store_pref, unique, tv.tv_sec, tv.tv_usec); if ( (fd = open(fname, O_CREAT|O_EXCL|O_RDWR, 00640)) < 0 ) { - if ( errno == EEXIST ) { sleep(2); continue; } + if ( errno == EEXIST ) { usleep(1000); continue; } perror(fname); cleanup(1); } diff --git a/org.glite.lb.client/src/notification.c b/org.glite.lb.client/src/notification.c index 5899d9b..2d91207 100644 --- a/org.glite.lb.client/src/notification.c +++ b/org.glite.lb.client/src/notification.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "glite/security/glite_gss.h" #include "glite/lb/notification.h" @@ -707,7 +708,7 @@ err: #endif /* NotifReceive */ { - fd_set fds; + struct pollfd pollfds[1]; struct sockaddr_in a; int recv_sock, alen; edg_wll_Event *event = NULL; @@ -731,8 +732,8 @@ err: } } - FD_ZERO(&fds); - FD_SET(fd,&fds); + pollfds[0].fd = fd; + pollfds[0].events = POLLIN; tv.tv_sec = timeout->tv_sec; tv.tv_usec = timeout->tv_usec; @@ -750,14 +751,18 @@ select: if (ctx->connPoolNotif[0].gss.context == GSS_C_NO_CONTEXT) { int ret; - switch(select(fd+1, &fds, NULL, NULL, &tv)) { + switch(poll(pollfds, 1, tv.tv_sec*1000+tv.tv_usec/1000)) { case -1: - edg_wll_SetError(ctx, errno, "select() failed"); + edg_wll_SetError(ctx, errno, "edg_wll_NotifReceive: poll() failed"); goto err; case 0: - edg_wll_SetError(ctx, ETIMEDOUT, "select() timeouted"); + edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive: poll() timed out"); goto err; default: + if (!(pollfds[0].revents & POLLIN)) { + edg_wll_SetError(ctx, errno, "edg_wll_NotifReceive: error on filedescriptor"); + goto err; + } break; } diff --git a/org.glite.lb.client/src/perftest_logjobs.c b/org.glite.lb.client/src/perftest_logjobs.c index e9b2178..99bde3b 100644 --- a/org.glite.lb.client/src/perftest_logjobs.c +++ b/org.glite.lb.client/src/perftest_logjobs.c @@ -13,7 +13,7 @@ extern int edg_wll_DoLogEventProxy(edg_wll_Context context, edg_wll_LogLine logl extern int edg_wll_DoLogEventDirect(edg_wll_Context context, edg_wll_LogLine logline); #define DEFAULT_SOCKET "/tmp/interlogger.sock" -#define DEFAULT_PREFIX "/tmp/dglogd.log" +#define DEFAULT_PREFIX EDG_WLL_LOG_PREFIX_DEFAULT /* extern char *optarg; diff --git a/org.glite.lb.client/src/producer.c b/org.glite.lb.client/src/producer.c index b7dec9c..f6afe96 100644 --- a/org.glite.lb.client/src/producer.c +++ b/org.glite.lb.client/src/producer.c @@ -27,6 +27,7 @@ #include "glite/lb/escape.h" #include "prod_proto.h" +#include "connection.h" static const char* socket_path="/tmp/lb_proxy_store.sock"; @@ -156,7 +157,7 @@ int edg_wll_DoLogEventProxy( edg_wll_LogLine logline) { int answer; - int flags; + int flags,retries; char *name_esc,*dguser; struct sockaddr_un saddr; edg_wll_PlainConnection conn; @@ -187,6 +188,10 @@ int edg_wll_DoLogEventProxy( close(conn.sock); goto edg_wll_DoLogEventProxy_end; } + +/* non-retry variant (pre bug #18994) + * XXX: what is the EISCONN case good for? conn.sock is created above. + * if (connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { if(errno != EISCONN) { edg_wll_SetError(context,answer = errno,"connect()"); @@ -194,6 +199,40 @@ int edg_wll_DoLogEventProxy( goto edg_wll_DoLogEventProxy_end; } } +*/ + + retries = 0; + while ((answer = connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr))) < 0 && + errno == EAGAIN && + context->p_tmp_timeout.tv_sec >= 0 && context->p_tmp_timeout.tv_usec >= 0 && + !(context->p_tmp_timeout.tv_sec == 0 && context->p_tmp_timeout.tv_usec == 0) + ) + { + struct timespec ns = { 0, PROXY_CONNECT_RETRY * 1000000 /* 10 ms */ },rem; + + nanosleep(&ns,&rem); + + context->p_tmp_timeout.tv_usec -= ns.tv_nsec/1000; + context->p_tmp_timeout.tv_usec += rem.tv_nsec/1000; + + context->p_tmp_timeout.tv_sec -= ns.tv_sec; + context->p_tmp_timeout.tv_sec += rem.tv_sec; + + if (context->p_tmp_timeout.tv_usec < 0) { + context->p_tmp_timeout.tv_usec += 1000000; + context->p_tmp_timeout.tv_sec--; + } + retries++; + } + + if (answer) { + if (errno == EAGAIN) edg_wll_SetError(context,answer = ETIMEDOUT,"edg_wll_DoLogEventProxy connect()"); + else edg_wll_SetError(context,answer = errno,"connect()"); + close(conn.sock); + goto edg_wll_DoLogEventProxy_end; + } + +/* just debug if (retries) printf("edg_wll_DoLogEventProxy connect retries %d\n",retries); */ /* add DG.USER to the message: */ name_esc = edg_wll_LogEscape(context->p_user_lbproxy); @@ -701,10 +740,9 @@ int edg_wll_SetLoggingJobProxy( edg_wll_SetParamString(context, EDG_WLL_PARAM_LBPROXY_USER, user); /* query LBProxyServer for sequence code if not user-suplied */ -/* FIXME: doesn't work yet */ if (!code) { - edg_wll_QuerySequenceCodeProxy(context, job, &code_loc); - goto edg_wll_setloggingjobproxy_end; + if (edg_wll_QuerySequenceCodeProxy(context, job, &code_loc)) + goto edg_wll_setloggingjobproxy_end; } else { code_loc = strdup(code); } @@ -927,6 +965,8 @@ int edg_wll_RegisterSubjobs( edg_wlc_JobId const *psubjob; edg_wlc_JobId oldctxjob; char * oldctxseq; + int errcode = 0; + char * errdesc = NULL; if (edg_wll_GetLoggingJob(ctx, &oldctxjob)) return edg_wll_Error(ctx, NULL, NULL); oldctxseq = edg_wll_GetSequenceCode(ctx); @@ -937,14 +977,19 @@ int edg_wll_RegisterSubjobs( while (*pjdl != NULL) { if (edg_wll_RegisterSubjob(ctx, *psubjob, EDG_WLL_REGJOB_SIMPLE, *pjdl, ns, parent, 0, NULL, NULL) != 0) { + errcode = edg_wll_Error(ctx, NULL, &errdesc); goto edg_wll_registersubjobs_end; } pjdl++; psubjob++; } +edg_wll_registersubjobs_end: edg_wll_SetLoggingJob(ctx, oldctxjob, oldctxseq, EDG_WLL_SEQ_NORMAL); -edg_wll_registersubjobs_end: + if (errcode) { + edg_wll_SetError(ctx, errcode, errdesc); + free(errdesc); + } return edg_wll_Error(ctx, NULL, NULL); } @@ -959,6 +1004,8 @@ int edg_wll_RegisterSubjobsProxy( edg_wlc_JobId const *psubjob; edg_wlc_JobId oldctxjob; char * oldctxseq; + int errcode = 0; + char * errdesc = NULL; if (edg_wll_GetLoggingJob(ctx, &oldctxjob)) return edg_wll_Error(ctx, NULL, NULL); oldctxseq = edg_wll_GetSequenceCode(ctx); @@ -969,14 +1016,19 @@ int edg_wll_RegisterSubjobsProxy( while (*pjdl != NULL) { if (edg_wll_RegisterSubjobProxy(ctx, *psubjob, EDG_WLL_REGJOB_SIMPLE, *pjdl, ns, parent, 0, NULL, NULL) != 0) { + errcode = edg_wll_Error(ctx, NULL, &errdesc); goto edg_wll_registersubjobsproxy_end; } pjdl++; psubjob++; } +edg_wll_registersubjobsproxy_end: edg_wll_SetLoggingJobProxy(ctx, oldctxjob, oldctxseq, NULL, EDG_WLL_SEQ_NORMAL); -edg_wll_registersubjobsproxy_end: + if (errcode) { + edg_wll_SetError(ctx, errcode, errdesc); + free(errdesc); + } return edg_wll_Error(ctx, NULL, NULL); } diff --git a/org.glite.lb.client/test/producer_test.cpp b/org.glite.lb.client/test/producer_test.cpp index c2199c5..33da719 100644 --- a/org.glite.lb.client/test/producer_test.cpp +++ b/org.glite.lb.client/test/producer_test.cpp @@ -55,14 +55,14 @@ private: void log_proto_server(int con, char *logline) { int i; - char b[4]; + char b[5]; char *buf; ssize_t size, retsize; // read DGLOG retsize = read(con, b, 5); CPPUNIT_ASSERT(retsize == 5); - CPPUNIT_ASSERT(b[0] = 'D' && b[1] == 'G' && b[2] == 'L' && b[3] == 'O' && b[4] == 'G'); + CPPUNIT_ASSERT(b[0] == 'D' && b[1] == 'G' && b[2] == 'L' && b[3] == 'O' && b[4] == 'G'); // read size (including '\0', little endian) for (i = 0; i < 4; i++) diff --git a/org.glite.lb.common/interface/lb_maildir.h b/org.glite.lb.common/interface/lb_maildir.h index 45b2da8..50eb8d4 100644 --- a/org.glite.lb.common/interface/lb_maildir.h +++ b/org.glite.lb.common/interface/lb_maildir.h @@ -17,7 +17,7 @@ extern char lbm_errdesc[]; extern int edg_wll_MaildirInit(const char *); extern int edg_wll_MaildirStoreMsg(const char *, const char *, const char *); -extern int edg_wll_MaildirRetryTransStart(const char *, time_t, char **, char **); +extern int edg_wll_MaildirRetryTransStart(const char *, time_t, time_t, char **, char **); extern int edg_wll_MaildirTransStart(const char *, char **, char **); extern int edg_wll_MaildirTransEnd(const char *, char *, int); diff --git a/org.glite.lb.common/interface/log_proto.h b/org.glite.lb.common/interface/log_proto.h index 51996af..aeaf306 100644 --- a/org.glite.lb.common/interface/log_proto.h +++ b/org.glite.lb.common/interface/log_proto.h @@ -27,7 +27,7 @@ extern "C" { * default prefix for names of log files */ /** default prefix */ -#define EDG_WLL_LOG_PREFIX_DEFAULT "/tmp/dglogd.log" +#define EDG_WLL_LOG_PREFIX_DEFAULT "/var/glite/log/dglogd.log" /** diff --git a/org.glite.lb.common/project/version.properties b/org.glite.lb.common/project/version.properties index 98625a6..4523ba9 100644 --- a/org.glite.lb.common/project/version.properties +++ b/org.glite.lb.common/project/version.properties @@ -1,3 +1,3 @@ #Fri Sep 02 14:17:07 CEST 2005 -module.version=3.2.0 +module.version=4.0.0 module.age=0 diff --git a/org.glite.lb.common/src/lb_maildir.c b/org.glite.lb.common/src/lb_maildir.c index 8f48c49..126cb3e 100644 --- a/org.glite.lb.common/src/lb_maildir.c +++ b/org.glite.lb.common/src/lb_maildir.c @@ -6,6 +6,8 @@ #include #include #include +#include + #include "context-int.h" #include "lb_maildir.h" @@ -16,10 +18,11 @@ enum { LBMD_DIR_TMP = 0, LBMD_DIR_NEW, LBMD_DIR_WORK, - LBMD_DIR_POST + LBMD_DIR_POST, + LBMD_DIR_UNDELIVERABLE }; -static const char *dirs[] = { "tmp", "new", "work", "post" }; +static const char *dirs[] = { "tmp", "new", "work", "post", "undeliverable" }; #define MAX_ERR_LEN 1024 @@ -70,17 +73,17 @@ int edg_wll_MaildirInit( int edg_wll_MaildirStoreMsg( - const char *root, - const char *srvname, - const char *msg) + const char *root, + const char *srvname, + const char *msg) { - char fname[PATH_MAX], - newfname[PATH_MAX]; - int fhnd, - written, - msgsz, - ct, i; - struct timeval tv; + char fname[PATH_MAX], + newfname[PATH_MAX]; + int fhnd, + written, + msgsz, + ct, i; + struct timeval tv; if ( !root ) root = DEFAULT_ROOT; @@ -93,11 +96,10 @@ int edg_wll_MaildirStoreMsg( snprintf(lbm_errdesc, MAX_ERR_LEN, "Maximum tries limit reached with unsuccessful file creation"); return -1; } - gettimeofday(&tv,NULL); - snprintf(fname, PATH_MAX, "%s/%s/%ld.%ld_%d.%s", root, dirs[LBMD_DIR_TMP], - (long) tv.tv_sec, (long) tv.tv_usec, getpid(), srvname); + gettimeofday(&tv, NULL); + snprintf(fname, PATH_MAX, "%s/%s/%ld_%ld.%s", root, dirs[LBMD_DIR_TMP], tv.tv_sec, tv.tv_usec, srvname); if ( (fhnd = open(fname, O_CREAT|O_EXCL|O_WRONLY, 00600)) < 0 ) { - if ( errno == EEXIST ) { /* hypothetic error */ continue; } + if ( errno == EEXIST ) { usleep(1000); continue; } snprintf(lbm_errdesc, MAX_ERR_LEN, "Can't create file %s", fname); return -1; } @@ -172,21 +174,22 @@ int edg_wll_MaildirTransEnd( int edg_wll_MaildirRetryTransStart( - const char *root, - time_t tm, - char **msg, - char **fname) + const char *root, + time_t retry, + time_t remove, + char **msg, + char **fname) { - static DIR *dir = NULL; - struct dirent *ent; - time_t tlimit; - struct stat st; - char newfname[PATH_MAX], - oldfname[PATH_MAX], - *buf = NULL; - int fhnd, - toread, ct, - bufsz, bufuse; + static DIR *dir = NULL; + struct dirent *ent; + time_t tlimit_retry, tlimit_remove; + struct stat st; + char newfname[PATH_MAX], + oldfname[PATH_MAX], + *buf = NULL; + int fhnd, + toread, ct, + bufsz, bufuse; if ( !root ) root = DEFAULT_ROOT; @@ -200,7 +203,8 @@ int edg_wll_MaildirRetryTransStart( } } - tlimit = time(NULL) - tm; + tlimit_retry = time(NULL) - retry; + tlimit_remove = time(NULL) - remove; do { errno = 0; if ( !(ent = readdir(dir)) ) { @@ -224,7 +228,15 @@ int edg_wll_MaildirRetryTransStart( goto err; } - if ( st.st_ctime > tlimit ) continue; + /* if we cannot deliver the file for 'remove' time limit, */ + /* it is moved to undeliverable folder and forgotten */ + if ( st.st_mtime < tlimit_remove ) { + snprintf(newfname, PATH_MAX, "%s/%s/%s", + root, dirs[LBMD_DIR_UNDELIVERABLE], ent->d_name); + } + /* try to deliver file every 'retry' seconds */ + else if ( st.st_ctime > tlimit_retry ) continue; + if ( rename(oldfname, newfname) ) { if ( errno == ENOENT ) { @@ -235,8 +247,17 @@ int edg_wll_MaildirRetryTransStart( goto err; } } else { - /* we have found and moved the file with which we will work now */ - break; + if (st.st_mtime < tlimit_remove) { + /* we have moved undeliverable file to undeliverable folder */ + /* no other action needed */ + snprintf(oldfname, PATH_MAX, "%s/%s/%s", root, dirs[LBMD_DIR_TMP], ent->d_name); + unlink(oldfname); + continue; + } else { + /* we have found and moved the file to work folder */ + /* going to process it */ + break; + } } } while ( 1 ); @@ -266,6 +287,7 @@ int edg_wll_MaildirRetryTransStart( close(fhnd); if ( !(*fname = strdup(ent->d_name)) ) goto err; + buf[bufuse] = 0; *msg = buf; return 1; diff --git a/org.glite.lb.common/src/lb_plain_io.c b/org.glite.lb.common/src/lb_plain_io.c index 7915dfa..1de8e37 100644 --- a/org.glite.lb.common/src/lb_plain_io.c +++ b/org.glite.lb.common/src/lb_plain_io.c @@ -13,6 +13,10 @@ #include #include #include +#include +#ifndef INFTIM +#define INFTIM (-1) +#endif #include "lb_plain_io.h" @@ -68,7 +72,8 @@ int edg_wll_plain_read( struct timeval *to) { int ct, toread = 0; - fd_set fds; + struct pollfd pollfds[1]; + int polltime = 0; struct timeval timeout, before, after; @@ -89,11 +94,16 @@ int edg_wll_plain_read( toread = 0; do { - FD_ZERO(&fds); - FD_SET(conn->sock, &fds); - switch (select(conn->sock+1, &fds, NULL, NULL, to ? &timeout : NULL)) { - case 0: errno = ETIMEDOUT; goto cleanup; break; - case -1: goto cleanup; break; + pollfds[0].fd = conn->sock; + pollfds[0].events = POLLIN; + polltime = to ? (timeout.tv_sec*1000+timeout.tv_usec/1000) : INFTIM; + switch (poll(pollfds, 1, polltime)) { + case 0: errno = ETIMEDOUT; goto cleanup; break; + case -1: goto cleanup; break; + default: if (!(pollfds[0].revents & POLLIN)) { + errno = EIO; + goto cleanup; break; + } } if ( conn->bufUse == conn->bufSize ) { @@ -125,6 +135,7 @@ cleanup: if ( to->tv_sec < 0 ) to->tv_sec = to->tv_usec = 0; } + if ( errno == ECONNRESET) errno = ENOTCONN; if ( errno ) return -1; if ( conn->bufUse > 0 ) { @@ -173,7 +184,8 @@ int edg_wll_plain_write_full( { size_t written = 0; int ct = -1; - fd_set fds; + struct pollfd pollfds[1]; + int polltime = 0; struct timeval timeout, before, after; struct sigaction sa,osa; @@ -188,12 +200,18 @@ int edg_wll_plain_write_full( errno = 0; while ( written < bufsz ) { - FD_ZERO(&fds); - FD_SET(conn->sock, &fds); - switch ( select(conn->sock+1, NULL, &fds, NULL, to? &timeout: NULL) ) { + pollfds[0].fd = conn->sock; + pollfds[0].events = POLLOUT; + polltime = to ? (timeout.tv_sec*1000+timeout.tv_usec/1000) : INFTIM; + + switch (poll(pollfds, 1, polltime)) { case 0: errno = ETIMEDOUT; goto end; break; case -1: goto end; break; + default: if (!(pollfds[0].revents & POLLOUT)) { + errno = ENOTCONN; + goto end; break; + } } if ( (ct=write(conn->sock, ((char*)buf)+written, bufsz-written)) < 0 ) { if ( errno == EINTR ) { errno = 0; continue; } diff --git a/org.glite.lb.common/src/mini_http.c b/org.glite.lb.common/src/mini_http.c index fcb3157..0535aa6 100644 --- a/org.glite.lb.common/src/mini_http.c +++ b/org.glite.lb.common/src/mini_http.c @@ -55,6 +55,7 @@ edg_wll_ErrorCode edg_wll_http_recv(edg_wll_Context ctx,char **firstOut,char *** edg_wll_SetErrorGss(ctx, "receving HTTP request", &gss_code); goto error; case EDG_WLL_GSS_ERROR_ERRNO: + if (errno == ECONNRESET) errno = ENOTCONN; edg_wll_SetError(ctx,errno,"edg_wll_gss_read()"); goto error; case EDG_WLL_GSS_ERROR_TIMEOUT: diff --git a/org.glite.lb.common/src/notifid.c b/org.glite.lb.common/src/notifid.c index 8a1d5fe..ee3c162 100644 --- a/org.glite.lb.common/src/notifid.c +++ b/org.glite.lb.common/src/notifid.c @@ -86,3 +86,20 @@ char* edg_wll_NotifIdGetUnique(const edg_wll_NotifId notifid) free(id); return NULL; } + +edg_wll_NotifId * +edg_wll_NotifIdDup(const edg_wll_NotifId src) +{ + char *str; + edg_wll_NotifId id = NULL; + int ret; + + str = edg_wll_NotifIdUnparse(src); + if (str == NULL) + return NULL; + + ret = edg_wll_NotifIdParse((const char *)str, &id); + free(str); + + return id; +} diff --git a/org.glite.lb.logger/config/glite-lb-logger.default-properties b/org.glite.lb.logger/config/glite-lb-logger.default-properties index f6bb2eb..202f5aa 100644 --- a/org.glite.lb.logger/config/glite-lb-logger.default-properties +++ b/org.glite.lb.logger/config/glite-lb-logger.default-properties @@ -1,10 +1,10 @@ locallogger.port = 9002 -locallogger.file-prefix = /tmp/dglogd.log +locallogger.file-prefix = /var/glite/log/dglogd.log locallogger.socket = /tmp/interlogger.sock locallogger.cert = /etc/grid-security/hostcert.pem locallogger.key = /etc/grid-security/hostkey.pem locallogger.CAdir = /etc/grid-security/certificates -interlogger.file-prefix = /tmp/dglogd.log +interlogger.file-prefix = /var/glite/log/dglogd.log interlogger.socket = /tmp/interlogger.sock interlogger.cert = /etc/grid-security/hostcert.pem interlogger.key = /etc/grid-security/hostkey.pem diff --git a/org.glite.lb.logger/config/startup b/org.glite.lb.logger/config/startup index 0d1e095..b443151 100755 --- a/org.glite.lb.logger/config/startup +++ b/org.glite.lb.logger/config/startup @@ -35,6 +35,8 @@ start() [ -n "$GLITE_LB_LOGGER_PORT" ] && port="-p $GLITE_LB_LOGGER_PORT" + mkdir -p /var/glite/log + chown $GLITE_USER /var/glite/log echo -n Starting glite-lb-logd ... (cd /tmp && ls -f /tmp |fgrep ^dglogd_sock_ |xargs rm -f) su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-logd \ diff --git a/org.glite.lb.logger/project/version.properties b/org.glite.lb.logger/project/version.properties index 0463660..c3dfb91 100644 --- a/org.glite.lb.logger/project/version.properties +++ b/org.glite.lb.logger/project/version.properties @@ -1,3 +1,3 @@ #Fri Sep 02 14:18:17 CEST 2005 -module.version=1.4.0 +module.version=1.3.3 module.age=0 diff --git a/org.glite.lb.logger/src/interlogd.c b/org.glite.lb.logger/src/interlogd.c index 3281718..a8527b9 100644 --- a/org.glite.lb.logger/src/interlogd.c +++ b/org.glite.lb.logger/src/interlogd.c @@ -13,6 +13,7 @@ #include "interlogd.h" #include "glite/lb/consumer.h" +#include "glite/lb/log_proto.h" #include "glite/security/glite_gss.h" #ifdef LB_PERF #include "glite/lb/lb_perftest.h" @@ -23,7 +24,7 @@ #define DEFAULT_PREFIX "/tmp/notif_events" #define DEFAULT_SOCKET "/tmp/notif_interlogger.sock" #else -#define DEFAULT_PREFIX "/tmp/dglogd.log" +#define DEFAULT_PREFIX EDG_WLL_LOG_PREFIX_DEFAULT #define DEFAULT_SOCKET "/tmp/interlogger.sock" #endif diff --git a/org.glite.lb.logger/src/logd.c b/org.glite.lb.logger/src/logd.c index 1fbd625..775f789 100644 --- a/org.glite.lb.logger/src/logd.c +++ b/org.glite.lb.logger/src/logd.c @@ -238,8 +238,7 @@ int main(int argc, char *argv[]) /* welcome */ fprintf(stdout,"\ -This is LocalLogger, part of Workload Management System in EU DataGrid.\ -Copyright (c) 2002 CERN, INFN and CESNET on behalf of the EU DataGrid.\n"); +This is LocalLogger, part of Workload Management System in EU DataGrid & EGEE.\n"); /* get arguments */ while ((opt = getopt_long(argc,argv, diff --git a/org.glite.lb.logger/src/send_event.c b/org.glite.lb.logger/src/send_event.c index cc2a55f..24e9e22 100644 --- a/org.glite.lb.logger/src/send_event.c +++ b/org.glite.lb.logger/src/send_event.c @@ -250,6 +250,7 @@ event_queue_send(struct event_queue *eq) size_t bytes_sent; struct timeval tv; edg_wll_GssStatus gss_stat; + int events_sent = 0; clear_error(); @@ -268,7 +269,14 @@ event_queue_send(struct event_queue *eq) eq->timeout = TIMEOUT; return(0); } - + if(ret < 0) { + if (ret == EDG_WLL_GSS_ERROR_ERRNO && errno == EPIPE && events_sent > 0) + eq->timeout = 0; + else + eq->timeout = TIMEOUT; + return(0); + } + if((code = get_reply(eq, &rep, &code_min)) < 0) { /* could not get the reply properly, so try again later */ il_log(LOG_ERR, " error reading server %s reply:\n %s\n", eq->dest_name, error_get_msg()); @@ -319,6 +327,7 @@ event_queue_send(struct event_queue *eq) il_log(LOG_ERR, "send_event: %s\n", error_get_msg()); event_queue_remove(eq); + events_sent++; break; } /* switch */ diff --git a/org.glite.lb.server-bones/project/version.properties b/org.glite.lb.server-bones/project/version.properties index 0d628ec..eac2bae 100644 --- a/org.glite.lb.server-bones/project/version.properties +++ b/org.glite.lb.server-bones/project/version.properties @@ -1,3 +1,3 @@ #Fri Sep 02 14:17:59 CEST 2005 -module.version=2.3.0 +module.version=2.2.2 module.age=0 diff --git a/org.glite.lb.server-bones/src/srvbones.c b/org.glite.lb.server-bones/src/srvbones.c index 72f21eb..cdac73e 100644 --- a/org.glite.lb.server-bones/src/srvbones.c +++ b/org.glite.lb.server-bones/src/srvbones.c @@ -333,7 +333,7 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) */ exit(1); - while ( !die && req_cnt < set_slave_reqs_max) + while ( !die && (req_cnt < set_slave_reqs_max || (conn >= 0 && first_request))) { fd_set fds; int max = sock, @@ -458,7 +458,7 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) kick_client = KICK_LOAD; } - if (req_cnt >= set_slave_reqs_max) kick_client = KICK_COUNT; + if (req_cnt >= set_slave_reqs_max && !first_request) kick_client = KICK_COUNT; if ( kick_client && conn >= 0 ) { @@ -475,8 +475,6 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) conn = newconn; srv = newsrv; gettimeofday(&client_start, NULL); - client_done.tv_sec = client_start.tv_sec; - client_done.tv_usec = client_start.tv_usec; switch ( send(sock, &seq, sizeof(seq), 0) ) { @@ -516,6 +514,7 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) conn = srv = -1; continue; } + gettimeofday(&client_done, NULL); first_request = 1; } } diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index 74da7b4..a81a14e 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -115,7 +115,7 @@ SOLINK:=libtool --mode=link ${CC} -module ${LDFLAGS} -rpath ${stagedir}/lib LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} INSTALL:=libtool --mode=install install LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} -XSLTPROC:=xsltproc +XSLTPROC:=xsltproc --novalid GLOBUS_LIBS:= -L${globus_prefix}/lib \ -lglobus_common_${nothrflavour} \ diff --git a/org.glite.lb.server/interface/job-attrs.xsd b/org.glite.lb.server/interface/job-attrs.xsd index 2d5cf9e..7d08482 100644 --- a/org.glite.lb.server/interface/job-attrs.xsd +++ b/org.glite.lb.server/interface/job-attrs.xsd @@ -35,11 +35,13 @@ - - - - - + + + + + + + @@ -55,15 +57,23 @@ + + + + + - Job owner according to LB + Job owner according to LB + + + @@ -96,6 +106,7 @@ + @@ -51,6 +52,7 @@ + + +