From: Aleš Křenek Date: Fri, 23 Mar 2007 11:55:17 +0000 (+0000) Subject: - avoid deadlock by keeping only a single semaphore at time X-Git-Tag: merge_31_head_dst~2 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=29c0e326f686e86025472d4ee40cc2043371af71;p=jra1mw.git - avoid deadlock by keeping only a single semaphore at time - minor fixes (missing prototypes etc.) --- diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index a0c93fa..33b33e0 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -382,7 +382,7 @@ install: mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix} ; \ (cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix}) ; \ install -m 644 ${STATIC_LIB_BK} ${PREFIX}/lib; \ - if [ x${LB_STANDALONE} = x ]; then \ + if [ x${LB_STANDALONE} = x -a x${PLUGIN_LIB} != x ]; then \ ${INSTALL} -m 755 ${PLUGIN_LIB} ${PREFIX}/lib; \ fi; \ ${INSTALL} -m 644 ${top_srcdir}/interface/srv_perf.h ${PREFIX}/include/${globalprefix}/${lbprefix}; \ diff --git a/org.glite.lb.server/interface/store.h b/org.glite.lb.server/interface/store.h index c42bef2..17e71ac 100644 --- a/org.glite.lb.server/interface/store.h +++ b/org.glite.lb.server/interface/store.h @@ -45,6 +45,8 @@ int db_store(edg_wll_Context,char *, char *); int db_parent_store(edg_wll_Context, edg_wll_Event *, intJobStat *); int handle_request(edg_wll_Context,char *); int create_reply(const edg_wll_Context,char **); +int trans_db_store(edg_wll_Context,char *,edg_wll_Event *,intJobStat *); + int edg_wll_delete_event(edg_wll_Context,const char *, int); diff --git a/org.glite.lb.server/src/db_store.c b/org.glite.lb.server/src/db_store.c index e749423..4513638 100644 --- a/org.glite.lb.server/src/db_store.c +++ b/org.glite.lb.server/src/db_store.c @@ -15,6 +15,7 @@ #include "lbs_db.h" #include "lock.h" #include "il_lbproxy.h" +#include "jobstat.h" #ifdef LB_PERF #include "glite/lb/lb_perftest.h" @@ -95,7 +96,9 @@ db_store(edg_wll_Context ctx,char *ucs, char *event) err = edg_wll_StepIntState(ctx,ev->any.jobId, ev, seq, ctx->isProxy? NULL: &newstat); } - if (edg_wll_UnlockJob(ctx,ev->any.jobId)) goto err; + /* XXX: in edg_wll_StepIntState() + * if (edg_wll_UnlockJob(ctx,ev->any.jobId)) goto err; + */ if (err) goto err; db_actual_store(ctx, event, ev, &newstat); diff --git a/org.glite.lb.server/src/jobstat.c b/org.glite.lb.server/src/jobstat.c index 6573889..e03ce05 100644 --- a/org.glite.lb.server/src/jobstat.c +++ b/org.glite.lb.server/src/jobstat.c @@ -972,6 +972,8 @@ edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context ctx, /* * update stored state according to the new event * (must be called with the job locked) + + * XXX: job is locked on entry, unlocked in this function */ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, @@ -1000,9 +1002,12 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, res = processEvent(ijsp, e, seq, be_strict, &errstring); if (res == RET_FATAL || res == RET_INTERNAL) { /* !strict */ edg_wll_FreeStatus(&oldstat); + edg_wll_UnlockJob(ctx,job); /* XXX: error lost */ return edg_wll_SetError(ctx, EINVAL, errstring); } edg_wll_StoreIntState(ctx, ijsp, seq); + if (edg_wll_UnlockJob(ctx,job)) goto err; + edg_wll_UpdateStatistics(ctx,&oldstat,e,&ijsp->pub); /* check whether subjob state change does not change parent state */ @@ -1026,6 +1031,12 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, /* FIXME: we miss state change in the case of seq != 0 * Does anybody care? */ + /* FIXME: collection parent status is wrong in this case. + However, it should not happen (frequently). + Right approach is computing parent status from scratch. + */ + + if (edg_wll_UnlockJob(ctx,job)) goto err; edg_wll_UpdateStatistics(ctx,NULL,e,&jobstat.pub); if (ctx->rgma_export) write2rgma_status(&jobstat.pub); @@ -1036,6 +1047,8 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, } else destroy_intJobStat(&jobstat); } + else edg_wll_UnlockJob(ctx,job); +err: return edg_wll_Error(ctx, NULL, NULL); } diff --git a/org.glite.lb.server/src/jobstat.h b/org.glite.lb.server/src/jobstat.h index 84f3e32..8514751 100644 --- a/org.glite.lb.server/src/jobstat.h +++ b/org.glite.lb.server/src/jobstat.h @@ -78,6 +78,9 @@ edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context, intJobStat *, int); edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context, edg_wlc_JobId, char *icnames, char *values, edg_wll_bufInsert *bi); edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context , edg_wlc_JobId , int, intJobStat **); +edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context,edg_wlc_JobId,edg_wll_Event *,int,intJobStat *,edg_wll_JobStat *); + + intJobStat* dec_intJobStat(char *, char **); char *enc_intJobStat(char *, intJobStat* );