Check the LB web services (there are some people trying to use it).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 30 Jun 2006 16:32:24 +0000 (16:32 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 30 Jun 2006 16:32:24 +0000 (16:32 +0000)
Fixed bug in QueryEvents operation.

org.glite.lb.server/examples/ws_getversion.c
org.glite.lb.server/examples/ws_joblog.c
org.glite.lb.server/examples/ws_jobstat.c
org.glite.lb.server/examples/ws_query_ex.c
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/ws_typeref.c.T

index 8560cfb..dcd3ae7 100644 (file)
@@ -5,6 +5,12 @@
 #include "glite/lb/consumer.h"
 
 #include "bk_ws_H.h"
+#include "ws_fault.h"
+
+#include "soap_version.h"
+#if GSOAP_VERSION <= 20602
+#define soap_call___lb__GetVersion soap_call___ns1__GetVersion
+#endif
 
 #include "LoggingAndBookkeeping.nsmap"
 
@@ -41,7 +47,7 @@ int main(int argc,char** argv)
        while ((opt = getopt_long(argc, argv, "hm:", opts, NULL)) != EOF) switch (opt)
        {
        case 'h': usage(name); return 0;
-       case 'm': server = strdup(optarg); break;
+       case 'm': server = optarg; break;
        case '?': usage(name); return 1;
        }
 
@@ -57,7 +63,7 @@ int main(int argc,char** argv)
                return 1;
        }
 
-/*    memset(&in, 0, sizeof(in));*/
+    memset(&in, 0, sizeof(in));
     memset(&out, 0, sizeof(out));
     switch (err = soap_call___lb__GetVersion(&soap, server, "", &in, &out))
        {
@@ -77,7 +83,10 @@ int main(int argc,char** argv)
                soap_print_fault(&soap, stderr);
     }
 
+    soap_end(&soap);
     soap_done(&soap);
+    glite_gsplugin_free_context(gsplugin_ctx);
+    edg_wll_FreeContext(ctx);
 
     return 0;
 }
index e197df0..fc86a38 100644 (file)
@@ -57,8 +57,8 @@ int main(int argc,char** argv)
        while ((opt = getopt_long(argc, argv, "hm:j:", opts, NULL)) != EOF) switch (opt)
        {
        case 'h': usage(name); return 0;
-       case 'm': server = strdup(optarg); break;
-       case 'j': jobid = strdup(optarg); break;
+       case 'm': server = optarg; break;
+       case 'j': jobid = optarg; break;
        case '?': usage(name); return 1;
        }
 
@@ -87,7 +87,7 @@ int main(int argc,char** argv)
        glite_gsplugin_set_udata(mydlo, ctx);
 
 
-       /* prepare job log quary */
+       /* prepare job log query */
        memset(j,0,sizeof j);
        memset(e,0,sizeof e);
 
@@ -97,19 +97,21 @@ int main(int argc,char** argv)
 
        
        jconds = (edg_wll_QueryRec **) calloc(2, sizeof(edg_wll_QueryRec *));
-       for ( i = 0; i < 2; i++ )
+       for ( i = 0; i < 1; i++ )
        {
                jconds[i] = (edg_wll_QueryRec *) calloc(2, sizeof(edg_wll_QueryRec));
                jconds[i][0] = j[i];
        }
 
-       econds = (edg_wll_QueryRec **) calloc(1, sizeof(edg_wll_QueryRec *));
+/*     econds = (edg_wll_QueryRec **) calloc(1, sizeof(edg_wll_QueryRec *));
        for ( i = 0; i < 1; i++ )
        {
                econds[i] = (edg_wll_QueryRec *) calloc(1, sizeof(edg_wll_QueryRec));
                econds[i][0] = e[i];
-       }
+       }*/
 
+       memset(&in, 0, sizeof in);
+       memset(&out, 0, sizeof out);
 
        if (edg_wll_QueryCondsExtToSoap(mydlo, (const edg_wll_QueryRec **)jconds,
                        &in.__sizejobConditions, &in.jobConditions) != SOAP_OK) {
@@ -117,6 +119,12 @@ int main(int argc,char** argv)
                return(1);
        }
 
+       for (i = 0; jconds[i]; i++) {
+               if (jconds[i]) edg_wlc_JobIdFree(jconds[i][0].value.j);
+               free(jconds[i]);
+       }
+       free(jconds);
+
        //edg_wll_QueryCondsExtToSoap(mydlo, (const edg_wll_QueryRec **)econds,
        //      &in.__sizeeventConditions, &in.eventConditions);
 
@@ -155,6 +163,7 @@ int main(int argc,char** argv)
                edg_wll_FaultToErr(mydlo,ctx);
                edg_wll_Error(ctx,&et,&ed);
                fprintf(stderr,"%s: %s (%s)\n",argv[0],et,ed);
+               soap_done(mydlo);
                exit(1);
                }
        default:
@@ -162,7 +171,11 @@ int main(int argc,char** argv)
                soap_print_fault(mydlo,stderr);
        }
 
-       soap_dealloc(mydlo, out.events);
+       soap_end(mydlo/*, out.events*/);
+       soap_done(mydlo);
+       free(mydlo);
+       glite_gsplugin_free_context(gsplugin_ctx);
+       edg_wll_FreeContext(ctx);
        return 0;
 }
 
index f38c94f..2130a28 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "bk_ws_H.h"
 #include "ws_typeref.h"
+#include "ws_fault.h"
 
 #include "soap_version.h"
 
@@ -52,8 +53,8 @@ int main(int argc,char** argv)
        while ((opt = getopt_long(argc, argv, "hm:j:", opts, NULL)) != EOF) switch (opt)
        {
        case 'h': usage(name); return 0;
-       case 'm': server = strdup(optarg); break;
-       case 'j': jobid = strdup(optarg); break;
+       case 'm': server = optarg; break;
+       case 'j': jobid = optarg; break;
        case '?': usage(name); return 1;
        }
 
@@ -88,6 +89,7 @@ int main(int argc,char** argv)
 
                edg_wll_SoapToStatus(mydlo,out.stat,&s);
                printstat(s, 0);
+               edg_wll_FreeStatus(&s);
                }
                break;
        case SOAP_FAULT: 
@@ -105,12 +107,18 @@ int main(int argc,char** argv)
                soap_print_fault(mydlo,stderr);
     }
 
+    soap_end(mydlo);
+    soap_done(mydlo);
+    free(mydlo);
+    glite_gsplugin_free_context(gsplugin_ctx);
+    edg_wll_FreeContext(ctx);
+
     return 0;
 }
 
 static void printstat(edg_wll_JobStat stat, int level)
 {
-    char        *s, *j, ind[10];
+    char        *s, *j1, *j2, ind[10];
     int         i;
     time_t     t;
 
@@ -122,11 +130,11 @@ static void printstat(edg_wll_JobStat stat, int level)
     s = edg_wll_StatToString(stat.state);
 /* print whole flat structure */
     printf("%sstate : %s\n", ind, s);
-    printf("%sjobId : %s\n", ind, j = edg_wlc_JobIdUnparse(stat.jobId));
+    printf("%sjobId : %s\n", ind, j1 = edg_wlc_JobIdUnparse(stat.jobId));
     printf("%sowner : %s\n", ind, stat.owner);
     printf("%sjobtype : %s\n", ind, (stat.jobtype ? "DAG" : "SIMPLE") );
     printf("%sparent_job : %s\n", ind,
-            j = edg_wlc_JobIdUnparse(stat.parent_job));
+            j2 = edg_wlc_JobIdUnparse(stat.parent_job));
     if (stat.jobtype) {;
         printf("%sseed : %s\n", ind, stat.seed);
         printf("%schildren_num : %d\n", ind, stat.children_num);
@@ -168,9 +176,13 @@ static void printstat(edg_wll_JobStat stat, int level)
     printf("%sstateEnterTime : %ld.%06ld\n", ind, stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec);
     printf("%sstateEnterTimes : \n",ind);
     if (stat.stateEnterTimes) for (i=1; i<=stat.stateEnterTimes[0]; i++) {
-       time_t  t = stat.stateEnterTimes[i];
-        printf("%s%14s  %s", ind, edg_wll_StatToString(i-1), (stat.stateEnterTimes[i] == 0) ?
+       char *s;
+
+       s = edg_wll_StatToString(i-1);
+       t = stat.stateEnterTimes[i];
+        printf("%s%14s  %s", ind, s, (stat.stateEnterTimes[i] == 0) ?
             "    - not available -\n" : ctime(&t));
+       free(s);
     }
     printf("%slastUpdateTime : %ld.%06ld\n", ind, stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec);
     printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate);
@@ -178,6 +190,7 @@ static void printstat(edg_wll_JobStat stat, int level)
     printf("%sacl : %s\n", ind, stat.acl);
     printf("\n");
 
-    free(j);
+    free(j1);
+    free(j2);
     free(s);
 }
index 2f3bd62..1b627a4 100644 (file)
@@ -8,6 +8,12 @@
 #include "ws_fault.h"
 #include "ws_typeref.h"
 
+#include "soap_version.h"
+
+#if GSOAP_VERSION <= 20602
+#define soap_call___lb__QueryJobs soap_call___ns1__QueryJobs
+#endif
+
 #include "LoggingAndBookkeeping.nsmap"
 
 
@@ -37,6 +43,7 @@ int main(int argc,char** argv)
        int                                     opt, err;
        char                                    *server = "http://localhost:9003/",
                                                *name = NULL;
+       int                                     i, j;
 
        name = strrchr(argv[0],'/');
        if (name) name++; else name = argv[0];
@@ -44,7 +51,7 @@ int main(int argc,char** argv)
        while ((opt = getopt_long(argc, argv, "hm:", opts, NULL)) != EOF) switch (opt)
        {
        case 'h': usage(name); return 0;
-       case 'm': server = strdup(optarg); break;
+       case 'm': server = optarg; break;
        case '?': usage(name); return 1;
        }
 
@@ -86,6 +93,9 @@ int main(int argc,char** argv)
                exit(1);
        }
 
+       for (i = 0; conditions[i]; i++) free(conditions[i]);
+       free(conditions);
+
     err = soap_call___lb__QueryJobs(soap, server, "", qjobs, &out);
     switch ( err ) {
        case SOAP_OK: {
@@ -118,6 +128,12 @@ int main(int argc,char** argv)
                soap_print_fault(soap,stderr);
     }
 
+    soap_end(soap);
+    soap_done(soap);
+    free(soap);
+    glite_gsplugin_free_context(gsplugin_ctx);
+    edg_wll_FreeContext(ctx);
+
     return 0;
 }
 
index 24f5929..15ea8f1 100644 (file)
@@ -1265,7 +1265,7 @@ static void wait_for_open(edg_wll_Context ctx, const char *dbstring)
        }
 
        if (!ctx->use_transactions && transactions != 0) {
-               fprintf(stderr, "[%d]: transaction aren't supported!\n", getpid());
+               fprintf(stderr, "[%d]: transactions aren't supported!\n", getpid());
        }
        if (transactions >= 0) {
                ctx->use_transactions = transactions;
index 90b40f6..5853f2a 100644 (file)
@@ -603,7 +603,7 @@ int edg_wll_QueryCondsToSoap(
        }
 
        qc->__sizerecord = 0;
-       while ( in[qc->__sizerecord++].attr );
+       while ( in[qc->__sizerecord].attr ) qc->__sizerecord++;
 
        if ( !qc->__sizerecord )
                goto ret;
@@ -633,7 +633,7 @@ int edg_wll_SoapToQueryCondsExt(const struct lbt__queryConditions **in, int __si
        edg_wll_QueryRec  **qr;
 
        assert(out);
-       if ( !(qr = calloc(__sizecondition, sizeof(*qr))) ) return -1;
+       if ( !(qr = calloc(__sizecondition + 1, sizeof(*qr))) ) return -1;
        for ( i = 0; i < __sizecondition; i++ )
                if ( edg_wll_SoapToQueryConds(in[i], qr+i) ) goto err;