From 7f8d9373e9d36e7c3580cfeb92dd03b2402a9c47 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Voc=C5=AF?= Date: Thu, 8 Jun 2006 14:34:20 +0000 Subject: [PATCH] * modified interface of producer function (again) --- org.glite.lb.common/interface/lb_perftest.h | 4 +-- org.glite.lb.common/src/lb_perftest.c | 44 +++++++++++++++-------------- org.glite.lb.common/src/perftest_common.sh | 6 ++-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/org.glite.lb.common/interface/lb_perftest.h b/org.glite.lb.common/interface/lb_perftest.h index 206fc25..65e9d76 100644 --- a/org.glite.lb.common/interface/lb_perftest.h +++ b/org.glite.lb.common/interface/lb_perftest.h @@ -20,8 +20,8 @@ glite_wll_perftest_init(const char *host, /** hostname */ char * glite_wll_perftest_produceJobId(); -const char * -glite_wll_perftest_produceEventString(char **event); +int +glite_wll_perftest_produceEventString(char **event, char **jobid); int glite_wll_perftest_consumeEvent(edg_wll_Event *event); diff --git a/org.glite.lb.common/src/lb_perftest.c b/org.glite.lb.common/src/lb_perftest.c index 8548964..cd5355f 100644 --- a/org.glite.lb.common/src/lb_perftest.c +++ b/org.glite.lb.common/src/lb_perftest.c @@ -288,11 +288,12 @@ glite_wll_perftest_produceJobId() * For every nevents (one job) new jobid is generated and inserted into * event. The last event is termination - usertag. */ -const char * -glite_wll_perftest_produceEventString(char **event) +int +glite_wll_perftest_produceEventString(char **event, char **jobid) { static char *cur_jobid = NULL; char *e; + int len; assert(event != NULL); @@ -303,29 +304,29 @@ glite_wll_perftest_produceEventString(char **event) if(cur_job < 0) { if(pthread_mutex_unlock(&perftest_lock) < 0) abort(); - return(NULL); + return(0); } /* did we send all jobs? */ if(cur_job >= njobs) { /* construct termination event */ - if(trio_asprintf(&e, EDG_WLL_FORMAT_COMMON EDG_WLL_FORMAT_USERTAG "\n", - "now", /* date */ - "localhost", /* host */ - "highest", /* level */ - 0, /* priority */ - "UserInterface", /* source */ - "me again", /* source instance */ - "UserTag", /* event */ - cur_jobid, /* jobid */ - "last", /* sequence */ - PERFTEST_END_TAG_NAME, - PERFTEST_END_TAG_VALUE) < 0) { + if((len=trio_asprintf(&e, EDG_WLL_FORMAT_COMMON EDG_WLL_FORMAT_USERTAG "\n", + "now", /* date */ + "localhost", /* host */ + "highest", /* level */ + 0, /* priority */ + "UserInterface", /* source */ + "me again", /* source instance */ + "UserTag", /* event */ + cur_jobid, /* jobid */ + "last", /* sequence */ + PERFTEST_END_TAG_NAME, + PERFTEST_END_TAG_VALUE)) < 0) { fprintf(stderr, "produceEventString: error creating termination event\n"); if(pthread_mutex_unlock(&perftest_lock) < 0) abort(); - return(NULL); + return(-1); } /* and refuse to produce more */ @@ -360,22 +361,22 @@ glite_wll_perftest_produceEventString(char **event) fprintf(stderr, "produceEventString: error creating jobid\n"); if(pthread_mutex_unlock(&perftest_lock) < 0) abort(); - return(NULL); + return(-1); } if((cur_jobid=edg_wlc_JobIdUnparse(jobid)) == NULL) { fprintf(stderr, "produceEventString: error unparsing jobid\n"); if(pthread_mutex_unlock(&perftest_lock) < 0) abort(); - return(NULL); + return(-1); } } /* return current event with jobid filled in */ - if(trio_asprintf(&e, "DG.JOBID=\"%s\" %s", cur_jobid, events[cur_event]) < 0) { + if((len=trio_asprintf(&e, "DG.JOBID=\"%s\" %s", cur_jobid, events[cur_event])) < 0) { fprintf(stderr, "produceEventString: error generating event\n"); if(pthread_mutex_unlock(&perftest_lock) < 0) abort(); - return(NULL); + return(-1); } } @@ -390,7 +391,8 @@ glite_wll_perftest_produceEventString(char **event) if(pthread_mutex_unlock(&perftest_lock) < 0) abort(); - return(cur_jobid); + *jobid = cur_jobid; + return(len); } diff --git a/org.glite.lb.common/src/perftest_common.sh b/org.glite.lb.common/src/perftest_common.sh index 516f43a..0bef734 100644 --- a/org.glite.lb.common/src/perftest_common.sh +++ b/org.glite.lb.common/src/perftest_common.sh @@ -13,9 +13,9 @@ JOB_MAX_DAG=${JOB_MAX_DAG:-$STAGEDIR/examples/perftest/perf_dag_max_events.log} LOGJOBS=${LOGJOBS:-$STAGEDIR/sbin/glite-lb-perftest_logjobs} # some defaults for log files -CONSUMER_LOG=/tmp/perftest_consumer.log -PRODUCER_LOG=/tmp/perftest_producer.log -COMPONENT_LOG=/tmp/perftest_component.log +CONSUMER_LOG=/tmp/perftest_${USER}_consumer.log +PRODUCER_LOG=/tmp/perftest_${USER}_producer.log +COMPONENT_LOG=/tmp/perftest_${USER}_component.log check_file_readable() -- 1.8.2.3