use md5 string as job parameter
authorMiloš Mulač <mulac@civ.zcu.cz>
Mon, 3 Mar 2008 11:59:18 +0000 (11:59 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Mon, 3 Mar 2008 11:59:18 +0000 (11:59 +0000)
org.glite.lb.server/src/db_calls.c
org.glite.lb.server/src/db_calls.h
org.glite.lb.server/src/jobstat.c

index bc86fef..cbdb0d6 100644 (file)
@@ -58,21 +58,19 @@ clean:
 /* just lock one row corresponding to job in table jobs
  * lock_mode: 0 = lock in share mode / 1 = for update
  */
-int edg_wll_LockJobRow(edg_wll_Context ctx, glite_jobid_const_t job, int lock_mode) 
+int edg_wll_LockJobRow(edg_wll_Context ctx, const char *job, int lock_mode) 
 {
-       char                    *jobid_md5 = NULL;
        char                    *stmt = NULL;
        glite_lbu_Statement     sh;
        int                     nr;
 
 
        edg_wll_ResetError(ctx);
-       jobid_md5 = edg_wlc_JobIdGetUnique(job);
 
        if (lock_mode) 
-               trio_asprintf(&stmt, "select count(*) from jobs where jobid='%|Ss' for update", jobid_md5);
+               trio_asprintf(&stmt, "select count(*) from jobs where jobid='%|Ss' for update", job);
        else
-               trio_asprintf(&stmt, "select count(*) from jobs where jobid='%|Ss' lock in share mode", jobid_md5);
+               trio_asprintf(&stmt, "select count(*) from jobs where jobid='%|Ss' lock in share mode", job);
 
        if ((nr = edg_wll_ExecSQL(ctx,stmt,&sh)) < 0) goto cleanup;
        if (nr == 0) {
@@ -83,7 +81,6 @@ int edg_wll_LockJobRow(edg_wll_Context ctx, glite_jobid_const_t job, int lock_mo
 cleanup:
        if (sh) glite_lbu_FreeStmt(&sh);
        free(stmt); stmt = NULL;
-       free(jobid_md5);
 
        return edg_wll_Error(ctx, NULL, NULL);
 }
index 71a19da..ff4910d 100644 (file)
@@ -10,7 +10,7 @@ int edg_wll_jobMembership(edg_wll_Context ctx, glite_jobid_const_t job);
 
 #define edg_wll_LockJobRowInShareMode(X,Y) edg_wll_LockJobRow(X,Y,0)
 #define edg_wll_LockJobRowForUpdate(X,Y) edg_wll_LockJobRow(X,Y,1)
-int edg_wll_LockJobRow(edg_wll_Context ctx, glite_jobid_const_t job, int lock_mode);
+int edg_wll_LockJobRow(edg_wll_Context ctx, const char *job, int lock_mode);
 
 
 #endif /* GLITE_LB_LB_CALLS_H */
index 41add31..482fa35 100644 (file)
@@ -107,7 +107,7 @@ int edg_wll_JobStatusServer(
                whole_cycle = 0;
 
                if (edg_wll_Transaction(ctx)) goto rollback;
-               if (edg_wll_LockJobRowInShareMode(ctx, job)) goto rollback;;
+               if (edg_wll_LockJobRowInShareMode(ctx, md5_jobid)) goto rollback;;
 
 
                if (edg_wll_GetACL(ctx, job, &acl)) goto rollback;
@@ -384,7 +384,7 @@ int edg_wll_intJobStatus(
        if (edg_wll_QueryEventsServer(ctx,1, (const edg_wll_QueryRec **)jqra, NULL, &events)) {
                free(string_jobid);
                free(jqra);
-               free(intstat->pub.owner);
+               free(intstat->pub.owner); intstat->pub.owner = NULL;
                 return edg_wll_Error(ctx, NULL, NULL);
        }
        free(jqra);
@@ -394,7 +394,7 @@ int edg_wll_intJobStatus(
 
        if (num_events == 0) {
                free(string_jobid);
-               free(intstat->pub.owner);
+               free(intstat->pub.owner); intstat->pub.owner = NULL;
                return edg_wll_SetError(ctx,ENOENT,NULL);
        }
 
@@ -690,7 +690,7 @@ edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context ctx,
        jobid_md5 = edg_wlc_JobIdGetUnique(jobid);
 
        if (lock) {
-               edg_wll_LockJobRowForUpdate(ctx,jobid);
+               edg_wll_LockJobRowForUpdate(ctx,jobid_md5);
        }
 
        if (seq == -1) {