From: Zdeněk Salvet Date: Thu, 5 Mar 2009 08:53:55 +0000 (+0000) Subject: Optimize internal single job event queries (fixes deadlock handling X-Git-Tag: glite-lb-server_R_1_9_2_1~1 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=b95ba062bffca833d1fb82c136901aabcce87764;p=jra1mw.git Optimize internal single job event queries (fixes deadlock handling eventless jobs with outdated stored state too), remove memory leak. --- diff --git a/org.glite.lb.server/src/query.c b/org.glite.lb.server/src/query.c index 3d30c5b..38ad0e2 100644 --- a/org.glite.lb.server/src/query.c +++ b/org.glite.lb.server/src/query.c @@ -35,6 +35,7 @@ static int check_strict_jobid_cond(edg_wll_Context, const edg_wll_QueryRec **); static int cmp_string(const char *,edg_wll_QueryOp,const char *); static int is_all_query(const edg_wll_QueryRec **); +static int is_singlejob_query(const edg_wll_QueryRec **); @@ -61,7 +62,6 @@ int edg_wll_QueryEventsServer( char *peerid = NULL; char *can_peername = NULL, *can_peerid = NULL; edg_wlc_JobId *jobsfound; - edg_wll_JobStat *statesfound; char *jobstr; int ii; @@ -94,7 +94,15 @@ int edg_wll_QueryEventsServer( i = 0; out = calloc(1, sizeof(*out)); - if (edg_wll_QueryJobsServer(ctx, job_conditions, 0, &jobsfound, &statesfound)) goto cleanup; + if (noAuth && is_singlejob_query(job_conditions)) { + jobsfound = calloc(1, sizeof(*jobsfound)); + if (!jobsfound || edg_wlc_JobIdDup(job_conditions[0][0].value.j,&jobsfound[0])) { + edg_wll_SetError(ctx,ENOMEM,"edg_wll_QueryEventsServer(): error copying jobid"); + goto cleanup; + } + } else { + if (edg_wll_QueryJobsServer(ctx, job_conditions, 0, &jobsfound, NULL)) goto cleanup; + } for ( ii = 0; (jobsfound) && (jobsfound[ii]); ii++ ) { jobstr = edg_wlc_JobIdUnparse(jobsfound[ii]); @@ -1455,3 +1463,14 @@ static int is_all_query(const edg_wll_QueryRec **jc) return 0; } + +static int is_singlejob_query(const edg_wll_QueryRec **jc) +{ + if (!jc || !*jc) return 0; + + if (jc[0][0].attr == EDG_WLL_QUERY_ATTR_JOBID && + jc[0][0].op == EDG_WLL_QUERY_OP_EQUAL && + !jc[0][1].attr && !jc[1]) return 1; + + return 0; +}