From 4993d2b3f66977a868cc1cd5f3aef34781d73565 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20=C5=A0kr=C3=A1bal?= Date: Thu, 2 Dec 2004 11:57:36 +0000 Subject: [PATCH] - query seq code server call --- org.glite.lb.server/src/seqcode.c | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 org.glite.lb.server/src/seqcode.c diff --git a/org.glite.lb.server/src/seqcode.c b/org.glite.lb.server/src/seqcode.c new file mode 100644 index 0000000..584e43e --- /dev/null +++ b/org.glite.lb.server/src/seqcode.c @@ -0,0 +1,63 @@ +#include + +#include "glite/lb/context-int.h" +#include "glite/lb/trio.h" + +#include "get_events.h" +#include "store.h" +#include "lock.h" +#include "jobstat.h" +/* +#include "lb_authz.h" +*/ + + + +int edg_wll_QuerySequenceCodeServer(edg_wll_Context ctx, edg_wlc_JobId jobid, const char *source, char **seqcode) +{ + edg_wll_Stmt sh; + intJobStat *istat = NULL; + char *jobid_md5 = NULL, + *stmt = NULL, + *res = NULL, + *res_rest = NULL; + int nstates; + + + edg_wll_ResetError(ctx); + jobid_md5 = edg_wlc_JobIdGetUnique(jobid); + + trio_asprintf(&stmt, + "select int_status from states " + "where jobid='%|Ss' and version='%|Ss'", + jobid_md5, INTSTAT_VERSION); + + if ( stmt == NULL ) return edg_wll_SetError(ctx, ENOMEM, NULL); + + if ( (nstates = edg_wll_ExecStmt(ctx, stmt, &sh)) < 0 ) goto cleanup; + if ( nstates == 0 ) { + edg_wll_SetError(ctx, ENOENT, "no state in DB"); + goto cleanup; + } + if ( edg_wll_FetchRow(sh, &res) < 0 ) goto cleanup; + + istat = dec_intJobStat(res, &res_rest); + if ( res_rest && istat ) { + *seqcode = istat->last_seqcode; + istat->last_seqcode = NULL; + } + else edg_wll_SetError(ctx, EDG_WLL_ERROR_DB_CALL, + "error decoding DB intJobStatus"); + +cleanup: + free(res); + free(jobid_md5); + free(stmt); + edg_wll_FreeStmt(&sh); + if ( istat ) { + destroy_intJobStat(istat); + free(istat); + } + + return edg_wll_Error(ctx, NULL, NULL); +} -- 1.8.2.3