- mem bugs in database query part
authorMiloš Mulač <mulac@civ.zcu.cz>
Fri, 14 Oct 2005 12:00:21 +0000 (12:00 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Fri, 14 Oct 2005 12:00:21 +0000 (12:00 +0000)
- example enhance (still very raw)

org.glite.jp.index/Makefile
org.glite.jp.index/examples/jpis-test.c
org.glite.jp.index/src/conf.c
org.glite.jp.index/src/soap_ops.c

index d21b89c..a4e56ed 100644 (file)
@@ -66,7 +66,7 @@ EXA_OBJS:=${EXA_SRCS:.c=.o}
 COMMONLIB:=-lglite_jp_common
 SRVCOMMONLIB:=-lglite_jp_server_common
 BONESLIB:=-lglite_lb_server_bones
-TRIOLIB:=-lglite_lb_trio
+TRIOLIB:=-lglite_jp_trio
 
 ifneq (${mysql_prefix},/usr)
        ifeq ($(shell echo ${mysql_version} | cut -d. -f1,2),4.1)
@@ -87,7 +87,7 @@ ${daemon}: ${OBJS}
        ${LINK} -o $@ -export-dynamic ${OBJS} ${BONESLIB} ${TRIOLIB} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} ${MYSQLIB} ${SRVCOMMONLIB}
 
 ${example}: ${EXA_OBJS}
-       ${LINK} -o $@ ${EXA_OBJS} ${GSOAPLIB} ${GLOBUS_LIBS}
+       ${LINK} -o $@ ${EXA_OBJS} ${GSOAPLIB} ${GLOBUS_LIBS} ${COMMONLIB} ${TRIOLIB}
 
 jpis-db-internal: jpis-db-internal.o db_ops.o conf.o context.o
        ${LINK} -o $@ $+ ${COMMONLIB} ${SRVCOMMONLIB} ${GLOBUS_LIBS}
index 8becbe1..d0842dc 100644 (file)
@@ -4,6 +4,7 @@
 #include <assert.h>
 
 #include <glite/security/glite_gsplugin.h>
+#include "glite/jp/strmd5.h"
 
 #include "jpis_H.h"
 #include "jpis_.nsmap"
@@ -71,6 +72,7 @@ int main(int argc,char *argv[])
        soap_set_namespaces(soap, jpis__namespaces);
 
        soap_register_plugin(soap,glite_gsplugin);
+goto query;
        // test calls of server functions
        {
        // this call is issued by JPPS
@@ -83,7 +85,8 @@ int main(int argc,char *argv[])
 
 //XXX : need to register feed with feedid in.feedId in DB
 //this one work only because such feed in conf.c (umbar)
-               in.feedId = soap_strdup(soap, "-PSJ1xMg9Ngd62-Lm-mitg");
+               //in.feedId = soap_strdup(soap, str2md5("http://localhost:8901"));
+               in.feedId = soap_strdup(soap, "12345");
                in.feedDone = false_;
                in.__sizejobAttributes = 1;
                in.jobAttributes = soap_malloc(soap, 
@@ -99,7 +102,7 @@ int main(int argc,char *argv[])
                        rec->attributes[0] = soap_malloc(soap, sizeof(*(rec->attributes[0])));
                        rec->attributes[0]->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/JP/System:owner");
                        rec->attributes[0]->value =  soap_malloc(soap, sizeof(*(rec->attributes[0]->value)));
-                       rec->attributes[0]->value->string = soap_strdup(soap, "S:Ja");
+                       rec->attributes[0]->value->string = soap_strdup(soap, "CertSubj");
                        rec->attributes[0]->value->blob = NULL;
                        rec->attributes[0]->timestamp = 333;
                        rec->attributes[0]->origin = jptype__attrOrig__SYSTEM;
@@ -108,7 +111,7 @@ int main(int argc,char *argv[])
                        rec->attributes[1] = soap_malloc(soap, sizeof(*(rec->attributes[1])));
                        rec->attributes[1]->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus");
                        rec->attributes[1]->value =  soap_malloc(soap, sizeof(*(rec->attributes[0]->value)));
-                       rec->attributes[1]->value->string = soap_strdup(soap, "S:Done");
+                       rec->attributes[1]->value->string = soap_strdup(soap, "Done");
                        rec->attributes[1]->value->blob = NULL;
                        rec->attributes[1]->timestamp = 333;
                        rec->attributes[1]->origin = jptype__attrOrig__SYSTEM;
@@ -121,12 +124,14 @@ int main(int argc,char *argv[])
                check_fault(soap,
                        soap_call___jpsrv__UpdateJobs(soap,server,"",&in,&out));
        }
+query:
        {
        // this call is issued by user
                struct _jpelem__QueryJobs               in;
                struct jptype__indexQuery               *cond;
                struct jptype__indexQueryRecord         *rec;
                struct _jpelem__QueryJobsResponse       out;
+               int                                     i, j;
 
                
                in.__sizeconditions = 1;
@@ -145,7 +150,7 @@ int main(int argc,char *argv[])
                memset(rec, 0, sizeof(*rec));
                rec->op = jptype__queryOp__EQUAL;
                rec->value = soap_malloc(soap, sizeof(*(rec->value)));
-               rec->value->string = soap_strdup(soap, "Cancelled");
+               rec->value->string = soap_strdup(soap, "Done");
                rec->value->blob = NULL;
                
                *(cond->record) = rec;
@@ -163,6 +168,15 @@ int main(int argc,char *argv[])
 
                check_fault(soap,
                        soap_call___jpsrv__QueryJobs(soap, server, "",&in,&out));
+
+               for (j=0; j<out.__sizejobs; j++) {
+                       printf("jobid = %s\n",out.jobs[j]->jobid);
+                       for (i=0; i<out.jobs[j]->__sizeattributes; i++) {
+                               printf("\t%s = %s\n",
+                                       out.jobs[j]->attributes[i]->name,
+                                       out.jobs[j]->attributes[i]->value->string);
+                       }
+               }
        } 
 
        return 0;
index 3c956f9..0c6596a 100644 (file)
@@ -44,15 +44,14 @@ int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf
        conf->attrs[16] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:lastStatusHistory");
        conf->attrs[17] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:fullStatusHistory");
 
-       conf->indexed_attrs = calloc(9, sizeof(*conf->indexed_attrs));
+       conf->indexed_attrs = calloc(8, sizeof(*conf->indexed_attrs));
        conf->indexed_attrs[0] = strdup("http://egee.cesnet.cz/en/Schema/JP/System:owner");
        conf->indexed_attrs[1] = strdup("http://egee.cesnet.cz/en/Schema/JP/System:jobId");
        conf->indexed_attrs[2] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:user");
        conf->indexed_attrs[3] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus");
-       conf->indexed_attrs[4] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:aTag");
-       conf->indexed_attrs[5] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:UIHost");
-       conf->indexed_attrs[6] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:CE");
-       conf->indexed_attrs[7] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:RB");
+       conf->indexed_attrs[4] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:UIHost");
+       conf->indexed_attrs[5] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:CE");
+       conf->indexed_attrs[6] = strdup("http://egee.cesnet.cz/en/Schema/LB/Attributes:RB");
 
        // XXX: some plugin names should come here in future
        conf->plugins = NULL;
@@ -62,8 +61,8 @@ int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf
        conf->feeds = calloc(2, sizeof(*(conf->feeds)));
        
        conf->feeds[0] = calloc(1, sizeof(**(conf->feeds)));
-       conf->feeds[0]->PS_URL = strdup("http://umbar.ics.muni.cz:8901");
-//     conf->feeds[0]->PS_URL = strdup("http://localhost:8901");
+//     conf->feeds[0]->PS_URL = strdup("http://umbar.ics.muni.cz:8901");
+       conf->feeds[0]->PS_URL = strdup("http://localhost:8901");
 
        // all job since Epoche
        conf->feeds[0]->query = calloc(2,sizeof(*conf->feeds[0]->query));
index ca10d61..e36e4f4 100644 (file)
@@ -367,13 +367,17 @@ static int get_attr(struct soap *soap, glite_jpis_context_t ctx, char *jobid, ch
        i = 0;
        while ( (ret = glite_jp_db_fetchrow(stmt, &fv)) > 0 ) { 
                av = realloc(av, (i+1) * sizeof(*av));
-               av[i] = soap_malloc(soap, sizeof(*av[i]));
+               av[i] = soap_malloc(soap, sizeof(**av));
+               memset(av[i], 0, sizeof(**av));
 
                memset(&jav,0,sizeof(jav));
                if (glite_jp_attrval_from_db(ctx->jpctx, fv, &jav)) goto err;
                av[i]->name = soap_strdup(soap, attr_name);
+               av[i]->value = soap_malloc(soap, sizeof(*(av[i]->value)));
+               memset(av[i]->value, 0, sizeof(*(av[i]->value)));
                if (jav.binary) {
                        av[i]->value->blob = soap_malloc(soap, sizeof(*(av[i]->value->blob)));
+                       memset(av[i]->value->blob, 0, sizeof(*(av[i]->value->blob)));
                        av[i]->value->blob->__ptr = soap_malloc(soap, jav.size);
                        memcpy(av[i]->value->blob->__ptr, jav.value, jav.size);
                        av[i]->value->blob->__size = jav.size;
@@ -424,13 +428,11 @@ static int get_attrs(struct soap *soap, glite_jpis_context_t ctx, char *jobid, s
 
        /* sizeattributes & attributes */
        size = 0;
-       for (j=0; in->__sizeattributes; j++) {
+       for (j=0; j < in->__sizeattributes; j++) {
                if (get_attr(soap, ctx, jobid, in->attributes[j], &jr) ) goto err;
                if (jr.__sizeattributes > 0) {
                        av = realloc(av, (size + jr.__sizeattributes) * sizeof(*av));
-                       for (i=0; i<jr.__sizeattributes; i++)
-                               av[size+i] = jr.attributes[i];
-                       //memcpy(av[size], jr.attributes[0], jr.__sizeattributes * sizeof(*av));
+                       memcpy(&av[size], jr.attributes, jr.__sizeattributes * sizeof(*(jr.attributes)));
                        size += jr.__sizeattributes;
                        free(jr.attributes);
                }