From: Miloš Mulač Date: Mon, 26 Mar 2007 13:44:38 +0000 (+0000) Subject: always lock parent job of collection when updating its status X-Git-Tag: merge_31_3_head_after~16 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=d243fca0f1dad6ffa5531b88cae4049804288813;p=jra1mw.git always lock parent job of collection when updating its status --- diff --git a/org.glite.lb.server/src/jobstat.c b/org.glite.lb.server/src/jobstat.c index e03ce05..5fc8e17 100644 --- a/org.glite.lb.server/src/jobstat.c +++ b/org.glite.lb.server/src/jobstat.c @@ -720,6 +720,7 @@ static char* hist_to_string(int * hist) return s; } +#if 0 // should not be needed anymore /* checks whether parent jobid would generate the same sem.num. */ /* as children jobid */ @@ -733,30 +734,20 @@ static int dependent_parent_lock(edg_wll_Context ctx, edg_wlc_JobId p,edg_wlc_Jo if (p_id == c_id) return 1; else return 0; } +#endif static edg_wll_ErrorCode load_parent_intJobStat(edg_wll_Context ctx, intJobStat *cis, intJobStat **pis) { - if (*pis) return edg_wll_Error(ctx, NULL, NULL); // already loaded - - /* goes to err when id's are equal too; it just do nothing... */ - switch (dependent_parent_lock(ctx, cis->pub.parent_job, cis->pub.jobId)) { - case 0: - /* lock parent job only if semaphore id is different from children sem id */ - /* otherwise because children job is already locked, parent is also locked */ - if (edg_wll_LockJob(ctx,cis->pub.parent_job)) goto err; - break; - case 1: // already locked, load the state - break; - case -1: // fall through - default: - goto err; - break; - } + if (*pis) return edg_wll_Error(ctx, NULL, NULL); // already loaded and locked + + if (edg_wll_LockJob(ctx,cis->pub.parent_job)) goto err; if (edg_wll_LoadIntState(ctx, cis->pub.parent_job, - 1, pis)) goto err; + assert(*pis); // deadlock would happen with next call of this function + err: return edg_wll_Error(ctx, NULL, NULL); @@ -912,8 +903,8 @@ static edg_wll_ErrorCode update_parent_status(edg_wll_Context ctx, edg_wll_JobSt edg_wll_StoreSubjobHistogram(ctx, cis->pub.parent_job, pis); err: - if (!dependent_parent_lock(ctx, cis->pub.parent_job, cis->pub.jobId)) - edg_wll_UnlockJob(ctx,cis->pub.parent_job); + edg_wll_UnlockJob(ctx,cis->pub.parent_job); + if (pis) destroy_intJobStat(pis);