get rid of semaphore locks -- they are not used anymore
authorAleš Křenek <ljocha@ics.muni.cz>
Thu, 9 Oct 2008 12:57:51 +0000 (12:57 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Thu, 9 Oct 2008 12:57:51 +0000 (12:57 +0000)
org.glite.lb.common/interface/context-int.h
org.glite.lb.server/Makefile
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/jobstat.c
org.glite.lb.server/src/lock.c [deleted file]
org.glite.lb.server/src/lock.h [deleted file]
org.glite.lb.server/src/seqcode.c
org.glite.lb.server/src/srv_purge.c
org.glite.lb.server/src/store.c.T
org.glite.lb.server/src/write2rgma.c

index e5f5aba..b717155 100644 (file)
@@ -68,8 +68,6 @@ glite_lb_padded_struct(_edg_wll_Context,150,
        edg_wll_ConnPool        *connPoolNotif;         /* hold _one_ connection from notif-interlogger */
        edg_wll_ConnProxy       *connProxy;             /* holds one plain connection */
 
-       int             semaphores;
-       int             semset;
        edg_wll_QueryRec        **job_index;
        void            *job_index_cols;
        
index 15976af..9eb2de5 100644 (file)
@@ -161,7 +161,7 @@ BKSERVER_BASE_OBJS:= \
        bkserverd.o il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o \
        seqcode.o write2rgma.o lb_html.o lb_http.o lb_proto.o lb_xml_parse.o \
        lb_xml_parse_V21.o lb_text.o \
-       lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \
+       openserver.o query.o userjobs.o db_store.o request.o store.o \
        stored_master.o srv_purge.o server_state.o dump.o lb_authz.o load.o \
        notification.o il_notification.o notif_match.o stats.o db_calls.o db_supp.o
 
@@ -201,7 +201,7 @@ else
 endif
 
 INDEX_OBJS:= index.o index_parse.o jobstat_supp.o openserver.o \
-       jobstat.o query.o lock.o get_events.o write2rgma.o index_lex.o \
+       jobstat.o query.o get_events.o write2rgma.o index_lex.o \
        lb_authz.o store.o bkindex.o stats.o\
        request.o db_store.o srv_purge.o notif_match.o il_lbproxy.o dump.o lb_xml_parse.o il_notification.o lb_proto.o lb_text.o server_state.o lb_xml_parse_V21.o lb_html.o notification.o seqcode.o userjobs.o load.o db_calls.o db_supp.lo
 
@@ -228,7 +228,7 @@ LIB_OBJS_BK:= \
        il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o \
        seqcode.o lb_html.o lb_http.o lb_proto.o lb_xml_parse.o \
        lb_xml_parse_V21.o lb_text.o \
-       lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \
+       openserver.o query.o userjobs.o db_store.o request.o store.o \
        stored_master.o srv_purge.o server_state.o dump.o lb_authz.o load.o \
        notification.o il_notification.o notif_match.o stats.o write2rgma.o \
        db_calls.o db_supp.o
index fd8c46e..2635788 100644 (file)
@@ -25,8 +25,6 @@
 #include <arpa/nameser.h>
 #include <resolv.h>
 #include <ares.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
 #include <errno.h>
 
 #ifdef GLITE_LB_SERVER_WITH_WS
@@ -141,9 +139,7 @@ int                                 transactions = -1;
 int                                    use_dbcaps = 0;
 static int                             fake_port = 0;
 static char                      **super_users = NULL;
-static int                             slaves = 10,
-                                               semaphores = -1,
-                                               semset;
+static int                             slaves = 10;
 static char                       *purgeStorage = EDG_PURGE_STORAGE;
 static char                       *dumpStorage = EDG_DUMP_STORAGE;
 static char                       *jpregDir = JPREG_DEF_DIR;
@@ -187,7 +183,6 @@ static struct option opts[] = {
        {"mysql",       1, NULL,        'm'},
        {"noauth",      0, NULL,        'n'},
        {"slaves",      1, NULL,        's'},
-       {"semaphores",  1, NULL,        'l'},
        {"pidfile",     1, NULL,        'i'},
        {"purge-prefix",        1, NULL,        'S'},
        {"dump-prefix", 1, NULL,        'D'},
@@ -218,7 +213,7 @@ static struct option opts[] = {
        {NULL,0,NULL,0}
 };
 
-static const char *get_opt_string = "Ac:k:C:V:p:a:drm:ns:l:i:S:D:J:jR:F:xOL:N:X:Y:T:t:zb:gPBo:q:W:Z:"
+static const char *get_opt_string = "Ac:k:C:V:p:a:drm:ns:i:S:D:J:jR:F:xOL:N:X:Y:T:t:zb:gPBo:q:W:Z:"
 #ifdef GLITE_LB_SERVER_WITH_WS
        "w:"
 #endif
@@ -246,7 +241,6 @@ static void usage(char *me)
                "\t-r, --rgmaexport write state info to RGMA interface\n"
                "\t-n, --noauth\t don't check user identity with result owner\n"
                "\t-s, --slaves\t number of slave servers to fork\n"
-               "\t-l, --semaphores number of semaphores (job locks) to use\n"
                "\t-i, --pidfile\t file to store master pid\n"
                "\t-L, --limits\t query limits numbers in format \"events_limit:jobs_limit:size_limit\"\n"
                "\t-N, --notif-dur default[:max]\t Duration of notification registrations in seconds (default and maximal)\n"
@@ -377,7 +371,6 @@ int main(int argc, char *argv[])
        char                       *ws_port;
 #endif /* GLITE_LB_SERVER_WITH_WS */
        FILE                       *fpid;
-       key_t                           semkey;
        edg_wll_Context         ctx;
        edg_wll_GssStatus       gss_code;
        struct timeval          to;
@@ -423,7 +416,6 @@ int main(int argc, char *argv[])
                case 'm': dbstring = optarg; break;
                case 'n': noAuth = 1; break;
                case 's': slaves = atoi(optarg); break;
-               case 'l': semaphores = atoi(optarg); break;
                case 'S': purgeStorage = optarg; break;
                case 'D': dumpStorage = optarg; break;
                case 'J': jpregDir = optarg; jpreg = 1; break;
@@ -526,8 +518,6 @@ int main(int argc, char *argv[])
        if (fprintf(fpid, "%d", getpid()) <= 0) { perror(pidfile); return 1; }
        if (fclose(fpid) != 0) { perror(pidfile); return 1; }
 
-       semkey = ftok(pidfile,0);
-
        if (mode & SERVICE_SERVER) {
                if (check_mkdir(dumpStorage)) exit(1);
                if (check_mkdir(purgeStorage)) exit(1);
@@ -540,20 +530,6 @@ int main(int argc, char *argv[])
                }
        }
 
-       if (semaphores == -1) semaphores = slaves;
-       semset = semget(semkey, 0, 0);
-       if (semset >= 0) semctl(semset, 0, IPC_RMID);
-       semset = semget(semkey, semaphores, IPC_CREAT | 0600);
-       if (semset < 0) { perror("semget()"); return 1; }
-       dprintf(("Using %d semaphores, set id %d\n",semaphores,semset));
-       for (i=0; i<semaphores; i++)
-       {
-               struct sembuf   s;
-
-               s.sem_num = i; s.sem_op = 1; s.sem_flg = 0;
-               if (semop(semset,&s,1) == -1) { perror("semop()"); return 1; }
-       }
-       
        if (mode & SERVICE_SERVER) {
                if ( fake_host )
                {
@@ -802,7 +778,6 @@ int main(int argc, char *argv[])
        }
 
 
-       semctl(semset, 0, IPC_RMID, 0);
        unlink(pidfile);
 
        for ( i = 0; i < sizofa(service_table); i++ )
@@ -978,8 +953,6 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
        if ( jpreg ) ctx->jpreg_dir = strdup(jpregDir); else ctx->jpreg_dir = NULL;
        ctx->hardJobsLimit = hardJobsLimit;
        ctx->hardEventsLimit = hardEventsLimit;
-       ctx->semset = semset;
-       ctx->semaphores = semaphores;
        if ( noAuth ) ctx->noAuth = 1;
        ctx->rgma_export = rgma_export;
        memcpy(ctx->purge_timeout, purge_timeout, sizeof(ctx->purge_timeout));
@@ -1240,8 +1213,6 @@ int bk_handle_connection_proxy(int conn, struct timeval *timeout, void *data)
        ctx->isProxy = 1;
        ctx->noAuth = 1;
        ctx->noIndex = 1;
-       ctx->semset = semset;
-       ctx->semaphores = semaphores;
 
 
        if (fake_host)
index bfc9796..0af26a2 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "get_events.h"
 #include "store.h"
-#include "lock.h"
 #include "index.h"
 #include "jobstat.h"
 #include "lb_authz.h"
diff --git a/org.glite.lb.server/src/lock.c b/org.glite.lb.server/src/lock.c
deleted file mode 100644 (file)
index 8765f3e..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ident "$Header$"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-#include <errno.h>
-
-#include "glite/jobid/cjobid.h"
-#include "glite/lb/context-int.h"
-#include "lock.h"
-
-extern int debug;
-
-int edg_wll_JobSemaphore(const edg_wll_Context ctx, glite_jobid_const_t job)
-{
-       char    *un = edg_wlc_JobIdGetUnique(job);
-       int     n,i;
-       static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
-
-
-       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 % ctx->semaphores);
-}
-
-int edg_wll_LockUnlockJob(const edg_wll_Context ctx,glite_jobid_const_t job,int lock)
-{
-       struct sembuf   s;
-       int             n;
-
-               
-       if ((n=edg_wll_JobSemaphore(ctx, job)) == -1) return edg_wll_Error(ctx,NULL,NULL);
-
-       if (debug) fprintf(stderr,"[%d] try semop(%d,%d) \n",getpid(),n,lock);
-
-       s.sem_num = n;
-       s.sem_op = lock;
-       s.sem_flg = SEM_UNDO;
-
-       if (semop(ctx->semset,&s,1)) { 
-               if (debug) fprintf(stderr,"[%d] failed semop(%d,%d) \n",getpid(),n,lock);
-               return edg_wll_SetError(ctx,errno,"edg_wll_LockUnlockJob()");
-       }
-
-       if (debug) fprintf(stderr,"[%d] got semop(%d,%d) \n",getpid(),n,lock);
-       return edg_wll_ResetError(ctx);
-}
diff --git a/org.glite.lb.server/src/lock.h b/org.glite.lb.server/src/lock.h
deleted file mode 100644 (file)
index 2649d9a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef GLITE_LB_LOCK_H
-#define GLITE_LB_LOCK_H
-
-#ident "$Header$"
-
-#include "glite/lb/context.h"
-
-#define edg_wll_LockJob(ctx,job) edg_wll_LockUnlockJob((ctx),(job),-1)
-#define edg_wll_UnlockJob(ctx,job) edg_wll_LockUnlockJob((ctx),(job),1)
-
-int edg_wll_LockUnlockJob(const edg_wll_Context,glite_jobid_const_t,int);
-int edg_wll_JobSemaphore(const edg_wll_Context ctx, glite_jobid_const_t job);
-
-#endif /* GLITE_LB_LOCK_H */
index cc46616..a9f18f3 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "get_events.h"
 #include "store.h"
-#include "lock.h"
 #include "jobstat.h"
 /*
 #include "lb_authz.h"
index fae2d96..9d10138 100644 (file)
@@ -21,7 +21,6 @@
 #include "lb_html.h"
 #include "lb_proto.h"
 #include "store.h"
-#include "lock.h"
 #include "query.h"
 #include "get_events.h"
 #include "purge.h"
index 37a2b92..365268f 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "store.h"
 #include "get_events.h"
-#include "lock.h"
 #include "lb_authz.h"
 #include "jobstat.h"
 #include "db_calls.h"
index c6b4e4a..fe9075a 100755 (executable)
@@ -20,7 +20,6 @@
 
 #include "get_events.h"
 #include "store.h"
-#include "lock.h"
 #include "index.h"
 #include "jobstat.h"