GetSemID added
authorMiloš Mulač <mulac@civ.zcu.cz>
Tue, 17 Oct 2006 07:55:17 +0000 (07:55 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Tue, 17 Oct 2006 07:55:17 +0000 (07:55 +0000)
- needs audit!

org.glite.lb.server/Makefile
org.glite.lb.server/src/lock.c
org.glite.lb.server/src/lock.h

index 6037ecb..46a6b02 100644 (file)
@@ -250,7 +250,7 @@ else
     PLUGIN_LIB=glite_lb_plugin.la
 endif
 
-compile: glite_lb_bkserverd glite_lb_bkindex ${STATIC_LIB_BK} ${PLUGIN_LIB} store.c
+compile: glite_lb_bkserverd glite_lb_bkindex ${STATIC_LIB_BK} ${PLUGIN_LIB} store.c index.c
 
 
 check: compile test.xml test.query
index 6351846..b4cd987 100644 (file)
 
 extern int debug;
 
-int edg_wll_LockUnlockJob(const edg_wll_Context ctx,const edg_wlc_JobId job,int lock)
+int edg_wll_GetSemID(const edg_wll_Context ctx, const edg_wlc_JobId job)
 {
-       struct sembuf   s;
        char    *un = edg_wlc_JobIdGetUnique(job);
        int     n,i;
        static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
-       
-       if (!un) return edg_wll_SetError(ctx,EINVAL,"jobid");
+
+
+       if (!un) {
+               edg_wll_SetError(ctx,EINVAL,"jobid");
+               return -1;
+       }
 
        for (n=0; n<sizeof b64 && b64[n] != un[0]; n++);
        for (i=0; i<sizeof b64 && b64[i] != un[1]; i++);
        n += i<<6;
 
+       free(un);
+       return(n);
+}
+
+int edg_wll_LockUnlockJob(const edg_wll_Context ctx,const edg_wlc_JobId job,int lock)
+{
+       struct sembuf   s;
+       int             n;
+
+               
+       if ((n=edg_wll_GetSemID(ctx, job)) == -1) return edg_wll_Error(ctx,NULL,NULL);
+
        if (debug) fprintf(stderr,"[%d] semop(%d,%d) \n",getpid(),n % ctx->semaphores,lock);
 
        s.sem_num = n % ctx->semaphores;
index c67ec6d..85bb875 100644 (file)
@@ -2,3 +2,4 @@
 #define edg_wll_UnlockJob(ctx,job) edg_wll_LockUnlockJob((ctx),(job),1)
 
 int edg_wll_LockUnlockJob(const edg_wll_Context,const edg_wlc_JobId,int);
+int edg_wll_GetSemID(const edg_wll_Context ctx, const edg_wlc_JobId job);