better implementation of sequence code compatibility
authorMiloš Mulač <mulac@civ.zcu.cz>
Fri, 1 Dec 2006 14:25:58 +0000 (14:25 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Fri, 1 Dec 2006 14:25:58 +0000 (14:25 +0000)
org.glite.lb.common/interface/context-int.h
org.glite.lb.server/src/jobstat_supp.c
org.glite.lb.server/src/store.c.T

index 1c2fa43..f08c633 100644 (file)
@@ -18,7 +18,7 @@ typedef struct _edg_wll_SeqCode {
 } edg_wll_SeqCode;
 
 #define EDG_WLL_SEQ_NULL "UI=000000:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000:LBS=000000"
-
+#define EDG_WLL_SEQ_SIZE        103    /* strlen(EDG_WLL_SEQ_NULL)+1 */
 
 /* non-gsi one-element analogy of connPool for L&B Proxy server */
 typedef struct _edg_wll_ConnProxy {
index 8ac4259..c665cf6 100644 (file)
@@ -713,8 +713,12 @@ int component_seqcode(const char *a, edg_wll_Source index)
 {
        unsigned int    c[EDG_WLL_SOURCE__LAST];
        int             res;
+       char            sc[EDG_WLL_SEQ_SIZE];
 
-       res =  sscanf(a, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
+       if (!strstr(a, "LBS")) snprintf(sc,EDG_WLL_SEQ_SIZE,"%s:LBS=000000",a);
+       else snprintf(sc,EDG_WLL_SEQ_SIZE,"%s",a);
+
+       res =  sscanf(sc, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
                        &c[EDG_WLL_SOURCE_USER_INTERFACE],
                        &c[EDG_WLL_SOURCE_NETWORK_SERVER],
                        &c[EDG_WLL_SOURCE_WORKLOAD_MANAGER],
@@ -725,21 +729,25 @@ int component_seqcode(const char *a, edg_wll_Source index)
                        &c[EDG_WLL_SOURCE_APPLICATION],
                        &c[EDG_WLL_SOURCE_LB_SERVER]);
        if (res != EDG_WLL_SOURCE__LAST-1) {
-               syslog(LOG_ERR, "unparsable sequence code %s\n", a);
-               fprintf(stderr, "unparsable sequence code %s\n", a);
+               syslog(LOG_ERR, "unparsable sequence code %s\n", sc);
+               fprintf(stderr, "unparsable sequence code %s\n", sc);
                return -1;
        }
 
        return(c[index]);       
 }
 
-char * set_component_seqcode(char *s,edg_wll_Source index,int val)
+char * set_component_seqcode(char *a,edg_wll_Source index,int val)
 {
        unsigned int    c[EDG_WLL_SOURCE__LAST];
        int             res;
        char            *ret;
+       char            sc[EDG_WLL_SEQ_SIZE];
+
+       if (!strstr(a, "LBS")) snprintf(sc,EDG_WLL_SEQ_SIZE,"%s:LBS=000000",a);
+       else snprintf(sc,EDG_WLL_SEQ_SIZE,"%s",a);
 
-       res =  sscanf(s, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
+       res =  sscanf(sc, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
                        &c[EDG_WLL_SOURCE_USER_INTERFACE],
                        &c[EDG_WLL_SOURCE_NETWORK_SERVER],
                        &c[EDG_WLL_SOURCE_WORKLOAD_MANAGER],
@@ -750,8 +758,8 @@ char * set_component_seqcode(char *s,edg_wll_Source index,int val)
                        &c[EDG_WLL_SOURCE_APPLICATION],
                        &c[EDG_WLL_SOURCE_LB_SERVER]);
        if (res != EDG_WLL_SOURCE__LAST-1) {
-               syslog(LOG_ERR, "unparsable sequence code %s\n", s);
-               fprintf(stderr, "unparsable sequence code %s\n", s);
+               syslog(LOG_ERR, "unparsable sequence code %s\n", sc);
+               fprintf(stderr, "unparsable sequence code %s\n", sc);
                return NULL;
        }
 
@@ -794,10 +802,16 @@ int edg_wll_compare_seq(const char *a, const char *b)
        unsigned int    c[EDG_WLL_SOURCE__LAST];
        unsigned int    d[EDG_WLL_SOURCE__LAST];
        int             res, i;
+       char            sca[EDG_WLL_SEQ_SIZE], scb[EDG_WLL_SEQ_SIZE];
+
+       if (!strstr(a, "LBS")) snprintf(sca,EDG_WLL_SEQ_SIZE,"%s:LBS=000000",a);
+       else snprintf(sca,EDG_WLL_SEQ_SIZE,"%s",a);
+       if (!strstr(b, "LBS")) snprintf(scb,EDG_WLL_SEQ_SIZE,"%s:LBS=000000",b);
+       else snprintf(scb,EDG_WLL_SEQ_SIZE,"%s",b);
 
        assert(EDG_WLL_SOURCE__LAST == 10);
 
-       res =  sscanf(a, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
+       res =  sscanf(sca, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
                        &c[EDG_WLL_SOURCE_USER_INTERFACE],
                        &c[EDG_WLL_SOURCE_NETWORK_SERVER],
                        &c[EDG_WLL_SOURCE_WORKLOAD_MANAGER],
@@ -808,12 +822,12 @@ int edg_wll_compare_seq(const char *a, const char *b)
                        &c[EDG_WLL_SOURCE_APPLICATION],
                        &c[EDG_WLL_SOURCE_LB_SERVER]);
        if (res != EDG_WLL_SOURCE__LAST-1) {
-               syslog(LOG_ERR, "unparsable sequence code %s\n", a);
-               fprintf(stderr, "unparsable sequence code %s\n", a);
+               syslog(LOG_ERR, "unparsable sequence code %s\n", sca);
+               fprintf(stderr, "unparsable sequence code %s\n", sca);
                return -1;
        }
 
-       res =  sscanf(b, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
+       res =  sscanf(scb, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d",
                        &d[EDG_WLL_SOURCE_USER_INTERFACE],
                        &d[EDG_WLL_SOURCE_NETWORK_SERVER],
                        &d[EDG_WLL_SOURCE_WORKLOAD_MANAGER],
@@ -824,8 +838,8 @@ int edg_wll_compare_seq(const char *a, const char *b)
                        &d[EDG_WLL_SOURCE_APPLICATION],
                        &d[EDG_WLL_SOURCE_LB_SERVER]);
        if (res != EDG_WLL_SOURCE__LAST-1) {
-               syslog(LOG_ERR, "unparsable sequence code %s\n", b);
-               fprintf(stderr, "unparsable sequence code %s\n", b);
+               syslog(LOG_ERR, "unparsable sequence code %s\n", scb);
+               fprintf(stderr, "unparsable sequence code %s\n", scb);
                return 1;
        }
 
index 0192a44..1f4fcd3 100644 (file)
@@ -83,15 +83,6 @@ int edg_wll_StoreEvent(edg_wll_Context ctx,edg_wll_Event *e,int *seq)
 
        userid = strdup(strmd5(e->any.user,NULL));
 
-/* if old seq. code arrives, add LBS part to it */
-       if (!strstr(e->any.seqcode, "LBS")) {
-               char *new_seqcode;
-
-               asprintf(&new_seqcode,"%s:LBS=000000",e->any.seqcode);
-               free(e->any.seqcode);
-               e->any.seqcode = new_seqcode;
-       }
-
 /* make sure user record is there */
        if ((err = store_user(ctx,userid,e->any.user))) goto clean;