CFLAGS:= \
${WS_CFLAGS} ${DEBUG} \
-DVERSION=\"${version}\" \
+ -I${gsoap_prefix}/include -I${gsoap_prefix}/ \
-I${stagedir}/include -I${top_srcdir}/src -I. \
-I${top_srcdir}/interface \
-I${expat_prefix}/include \
-I${cares_prefix}/include \
- -I${gsoap_prefix}/include -I${gsoap_prefix}/ \
-I${classads_prefix}/include \
-I${voms_prefix}/include \
${COVERAGE_FLAGS} \
examples: ws_getversion ws_jobstat ws_query_ex ws_joblog
ws_getversion: ws_getversion.o ${WS_CLIENT_OBJS}
- ${LINK} -o $@ ws_getversion.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS}
+ ${LINK} -o $@ ws_getversion.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS}
ws_jobstat: ws_jobstat.o ${WS_CLIENT_OBJS}
${LINK} -o $@ ws_jobstat.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS}
ws_query_ex: ws_query_ex.o ${WS_CLIENT_OBJS}
${LINK} -o $@ ws_query_ex.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS}
-ws_query_ext: ws_query_ext.o ${WS_CLIENT_OBJS}
- ${LINK} -o $@ ws_query_ext.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS}
-
ws_joblog: ws_joblog.o ${WS_CLIENT_OBJS}
${LINK} -o $@ ws_joblog.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS}
${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-bkserverd
${INSTALL} -m 644 ${top_srcdir}/interface/job-attrs.xsd ${PREFIX}/interface
${INSTALL} -m 644 ${top_srcdir}/interface/job-record.xsd ${PREFIX}/interface
- ${INSTALL} -m 644 jp_job_attrs.h ${PREFIX}/include/${globalprefix}/${lbprefix}
if [ x${DOSTAGE} != xyes ]; then \
${INSTALL} -m 755 ${stagedir}/bin/glite-lb-notif-interlogd ${PREFIX}/bin; \
install -m 644 ${STATIC_LIB_BK} ${PREFIX}/lib; \
if [ x${LB_STANDALONE} = x -a x${PLUGIN_LIB} != x ]; then \
${INSTALL} -m 755 ${PLUGIN_LIB} ${PREFIX}/lib; \
+ ${INSTALL} -m 644 jp_job_attrs.h ${PREFIX}/include/${globalprefix}/${lbprefix} ; \
fi; \
${INSTALL} -m 644 ${top_srcdir}/interface/srv_perf.h ${PREFIX}/include/${globalprefix}/${lbprefix}; \
fi
[ -n "$GLITE_LB_SERVER_PIDFILE" ] && pidfile=$GLITE_LB_SERVER_PIDFILE ||
pidfile=$GLITE_LOCATION_VAR/glite-lb-bkserverd.pid
+[ -z "$GLITE_LB_NOTIF_SOCK" ] && GLITE_LB_NOTIF_SOCK="/tmp/glite-lb-notif.sock"
unset creds port
fi
[ -z "$GLITE_LB_EXPORT_DUMPDIR" ] && GLITE_LB_EXPORT_DUMPDIR=/tmp/dump
- purgedir="--dump-prefix $GLITE_LB_EXPORT_DUMPDIR"
+ dumpdir="--dump-prefix $GLITE_LB_EXPORT_DUMPDIR"
[ -d "$GLITE_LB_EXPORT_DUMPDIR" ] || mkdir -p "$GLITE_LB_EXPORT_DUMPDIR" && chown $GLITE_USER:$GLITE_GROUP -R "$GLITE_LB_EXPORT_DUMPDIR"
- [ -z "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] && GLITE_LB_EXPORT_JPREG_MAILDIR=/tmp/jpreg
- maildir="--jpreg-dir $GLITE_LB_EXPORT_JPREG_MAILDIR"
- [ -d "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] || mkdir -p "$GLITE_LB_EXPORT_JPREG_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP -R "$GLITE_LB_EXPORT_JPREG_MAILDIR"
+ [ -z "$GLITE_LB_EXPORT_PURGEDIR" ] && GLITE_LB_EXPORT_PURGEDIR=/tmp/purge
+ purgedir="--purge-prefix $GLITE_LB_EXPORT_PURGEDIR"
+ [ -d "$GLITE_LB_EXPORT_PURGEDIR" ] || mkdir -p "$GLITE_LB_EXPORT_PURGEDIR" && chown $GLITE_USER:$GLITE_GROUP -R "$GLITE_LB_EXPORT_PURGEDIR"
+
+ if [ x"$GLITE_LB_EXPORT_ENABLED" = x"true" ]; then
+ [ -z "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] && GLITE_LB_EXPORT_JPREG_MAILDIR=/tmp/jpreg
+ [ -d "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] || mkdir -p "$GLITE_LB_EXPORT_JPREG_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP -R "$GLITE_LB_EXPORT_JPREG_MAILDIR"
+ maildir="--jpreg-dir $GLITE_LB_EXPORT_JPREG_MAILDIR"
+ fi
+ super="--super-users-file $GLITE_LOCATION/etc/LB-super-users"
[ -z "$creds" ] && echo $0: WARNING: No credentials specified. Using default lookup which is dangerous. >&2
[ -n "$GLITE_LB_SERVER_PORT" ] && port="-p $GLITE_LB_SERVER_PORT"
[ -n "$GLITE_LB_SERVER_WPORT" ] && wport="-w $GLITE_LB_SERVER_WPORT"
-
- [ -z "$GLITE_LB_NOTIF_SOCK" ] && GLITE_LB_NOTIF_SOCK="/tmp/glite-lb-notif.sock"
[ -z "$GLITE_LB_NOTIF_FPREFIX" ] && GLITE_LB_NOTIF_FPREFIX="/var/tmp/glite-lb-notif"
echo -n Starting glite-lb-bkserver ...
su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-bkserverd \
--notif-il-sock=$GLITE_LB_NOTIF_SOCK \
--notif-il-fprefix=$GLITE_LB_NOTIF_FPREFIX \
- $creds -i $pidfile $port $wport $purgedir $maildir" \
+ $super $creds -i $pidfile $port $wport $dumpdir $purgedir $maildir" \
&& echo " done" || echo " FAILED"
echo -n Starting glite-lb-notif-interlogd ...
#include <getopt.h>
#include <stdsoap2.h>
-#include "glite/security/glite_gsplugin.h"
#include "glite/lb/consumer.h"
#include "glite/lb/events_parse.h"
+#include "soap_version.h"
+#include "glite/security/glite_gsplugin.h"
+#include "glite/security/glite_gscompat.h"
+
#include "bk_ws_H.h"
#include "ws_typeref.h"
#include "ws_fault.h"
-#include "soap_version.h"
-
#if GSOAP_VERSION <= 20602
#define soap_call___lb__QueryEvents soap_call___ns1__QueryEvents
#endif
struct soap *mydlo = soap_new();
struct _lbe__QueryEventsResponse out;
struct _lbe__QueryEvents in;
- edg_wll_QueryRec **jconds = NULL,
- **econds = NULL;
+ edg_wll_QueryRec **jconds = NULL;
edg_wll_QueryRec j[2], e[1];
int opt, err, i;
edg_wlc_JobId job;
glite_gsplugin_set_udata(mydlo, ctx);
-
/* prepare job log query */
memset(j,0,sizeof j);
memset(e,0,sizeof e);
#include <getopt.h>
#include <stdsoap2.h>
+#include "soap_version.h"
#include "glite/security/glite_gsplugin.h"
+#include "glite/security/glite_gscompat.h"
#include "glite/lb/consumer.h"
#include "bk_ws_H.h"
#include "ws_typeref.h"
#include "ws_fault.h"
-#include "soap_version.h"
-
#if GSOAP_VERSION <= 20602
#define soap_call___lb__JobStatus soap_call___ns1__JobStatus
#endif
struct soap *mydlo = soap_new();
struct _lbe__JobStatusResponse out;
struct _lbe__JobStatus in;
- struct lbt__jobFlags flags = { 0, NULL };
int opt, err;
char *server = "http://localhost:9003/",
*jobid = NULL,
glite_gsplugin_set_udata(mydlo, ctx);
- in.jobid = jobid;
- in.flags = &flags;
-
+ in.jobid = soap_strdup(mydlo, jobid);
+ in.flags = soap_malloc(mydlo, sizeof(*in.flags));
+ edg_wll_JobStatFlagsToSoap(mydlo, 0, in.flags);
switch (err = soap_call___lb__JobStatus(mydlo, server, "",&in,&out))
{
printf("%srsl : %s\n", ind, stat.rsl);
printf("%sreason : %s\n", ind, stat.reason);
printf("%slocation : %s\n", ind, stat.location);
- printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed);
+ printf("%sce_node : %s\n", ind, stat.ce_node);
+ printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed);
+// printf("%sdone_code : %d\n", ind, edg_wll_done_codeToString(stat.done_code));
printf("%sdone_code : %d\n", ind, stat.done_code);
printf("%sexit_code : %d\n", ind, stat.exit_code);
printf("%sresubmitted : %d\n", ind, stat.resubmitted);
printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate);
printf("%sexpectFrom : %s\n", ind, stat.expectFrom);
printf("%sacl : %s\n", ind, stat.acl);
+ printf("%spayload_running: %d\n", ind, stat.payload_running);
+ if (stat.possible_destinations) {
+ printf("%spossible_destinations : \n", ind);
+ for (i=0; stat.possible_destinations[i]; i++)
+ printf("%s\t%s \n", ind, stat.possible_destinations[i]);
+ }
+ if (stat.possible_ce_nodes) {
+ printf("%spossible_ce_nodes : \n", ind);
+ for (i=0; stat.possible_ce_nodes[i]; i++)
+ printf("%s\t%s \n", ind, stat.possible_ce_nodes[i]);
+ }
printf("\n");
free(j1);
#include <getopt.h>
#include <stdsoap2.h>
-#include "glite/security/glite_gsplugin.h"
#include "glite/lb/consumer.h"
+#include "soap_version.h"
+#include "glite/security/glite_gsplugin.h"
+#include "glite/security/glite_gscompat.h"
+
#include "bk_ws_H.h"
#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
int opt, err;
char *server = "http://localhost:9003/",
*name = NULL;
- int i, j;
+ int i;
name = strrchr(argv[0],'/');
if (name) name++; else name = argv[0];
conditions[1] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
conditions[1][0].attr = EDG_WLL_QUERY_ATTR_OWNER;
- conditions[1][0].op = EDG_WLL_QUERY_OP_EQUAL;
- conditions[1][0].value.c = NULL;
+#warning FIXME: NULL should work, use optional in WSDL?
+// conditions[1][0].op = EDG_WLL_QUERY_OP_EQUAL;
+// conditions[1][0].value.c = NULL;
+ conditions[1][0].op = EDG_WLL_QUERY_OP_UNEQUAL;
+ conditions[1][0].value.c = "x";
qjobs = soap_malloc(soap, sizeof(*qjobs));
memset(qjobs, 0, sizeof(*qjobs));
qjobs->flags = soap_malloc(soap, sizeof(*qjobs->flags));
memset(qjobs->flags, 0, sizeof(*qjobs->flags));
if (!qjobs->flags || edg_wll_QueryCondsExtToSoap(soap, (const edg_wll_QueryRec **)conditions, &qjobs->__sizeconditions, &qjobs->conditions)
- || edg_wll_JobStatFlagsToSoap(soap, 0, qjobs->flags) ) {
+ || edg_wll_JobStatFlagsToSoap(soap, EDG_WLL_STAT_CLASSADS || EDG_WLL_STAT_CHILDREN || EDG_WLL_STAT_CHILDSTAT, qjobs->flags) ) {
char *et,*ed;
fprintf(stderr, "%s: soap types conversion error...\n", argv[0]);
edg_wll_JobStatCode statCode;
- edg_wll_SoapToJobStatCode(out.states[i]->state, &statCode);
+ edg_wll_SoapToJobStatCode(GLITE_SECURITY_GSOAP_LIST_GET(out.states, i)->state, &statCode);
char *s = edg_wll_StatToString(statCode);
printf("%-65s%s\n", out.jobs[i], s);
free(s);
+/* don't care :-(
switch ( edg_wll_gss_watch_creds(server_cert, &cert_mtime) ) {
case 0: break;
case 1:
+*/
if ( !edg_wll_gss_acquire_cred_gsi(server_cert, server_key, &newcred, NULL, &gss_code) ) {
dprintf(("[%d] reloading credentials\n", getpid()));
gss_release_cred(&min_stat, &mycred);
mycred = newcred;
- } else { dprintf(("[%d] reloading credentials failed\n", getpid())); }
+ } else { dprintf(("[%d] reloading credentials failed, using old ones\n", getpid())); }
+/*
break;
case -1: dprintf(("[%d] edg_wll_gss_watch_creds failed\n", getpid())); break;
}
+*/
if ( edg_wll_InitContext(&ctx) )
{
default:
if (debug) fprintf(stderr, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
dprintf(("[%d] connection from %s:%d\n", getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port)));
+ free(ctx->connections->serverConnection->peerName);
+ ctx->connections->serverConnection->peerName = strdup(inet_ntoa(a.sin_addr));
break;
}
ctx->srvPort = ntohs(a.sin_port);
}
+/* XXX: ugly workaround, we may detect false expired certificated
+ * probably due to bug in Globus GSS/SSL. Treated as fatal,
+ * restarting the server solves the problem */
+
+#define _EXPIRED_CERTIFICATE_MESSAGE "certificate has expired"
+
if ( (ret = edg_wll_gss_accept(mycred, conn, timeout, &ctx->connections->serverConnection->gss, &gss_code)) )
{
if ( ret == EDG_WLL_GSS_ERROR_TIMEOUT )
{
- dprintf(("[%d] Client authentication failed - timeout reached, closing.\n", getpid()));
- if (!debug) syslog(LOG_ERR, "Client authentication failed - timeout reached");
+ dprintf(("[%d] %s: Client authentication failed - timeout reached, closing.\n", getpid(),ctx->connections->serverConnection->peerName));
+ if (!debug) syslog(LOG_ERR, "%s: Client authentication failed - timeout reached",ctx->connections->serverConnection->peerName);
+ }
+ else if (ret == EDG_WLL_GSS_ERROR_GSS) {
+ edg_wll_SetErrorGss(ctx,"Client authentication",&gss_code);
+ if (strstr(ctx->errDesc,_EXPIRED_CERTIFICATE_MESSAGE)) {
+ dprintf(("[%d] %s: false expired certificate: %s\n",getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc));
+ if (!debug) syslog(LOG_ERR,"[%d] %s: false expired certificate: %s",getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc);
+ edg_wll_FreeContext(ctx);
+ return -1;
+ }
}
else
{
- dprintf(("[%d] Client authentication failed, closing.\n", getpid()));
- if (!debug) syslog(LOG_ERR, "Client authentication failed");
+ dprintf(("[%d] %s: Client authentication failed, closing.\n", getpid(),ctx->connections->serverConnection->peerName));
+ if (!debug) syslog(LOG_ERR, "%s: Client authentication failed",ctx->connections->serverConnection->peerName);
}
edg_wll_FreeContext(ctx);
int cnt = 0;
if (!roots) {
- perror(file);
- return 1;
+ syslog(LOG_WARNING,"%s: %m, continuing without --super-users-file",file);
+ dprintf(("%s: %s, continuing without --super-users-file\n",file,strerror(errno)));
+ return 0;
}
while (!feof(roots)) {
#include "glite/lb/events.h"
#include "glite/lb/events_parse.h"
#include "glite/lb/trio.h"
+#include "glite/lb/producer.h"
#include "jobstat.h"
#include "get_events.h"
typedef struct _lb_handle {
edg_wll_Event **events;
edg_wll_JobStat status;
- lb_historyStatus **fullStatusHistory, **lastStatusHistory;
+ lb_historyStatus **fullStatusHistory, **lastStatusHistory*finalStatus;
glite_jpps_fplug_data_t* classad_plugin;
} lb_handle;
char *line;
int retval;
edg_wll_Context context;
- int nevents, maxnevents, i;
- glite_jp_error_t err;
+ int nevents, maxnevents, i;
+ glite_jp_error_t err;
+ char *id0 = NULL,*id = NULL;
glite_jp_clear_error(ctx);
h = calloc(1, sizeof(lb_handle));
free(ed);
goto fail;
}
+ if (nevents == 0) {
+ id0 = edg_wlc_JobIdGetUnique(h->events[nevents]->any.jobId );
+ } else {
+ id = edg_wlc_JobIdGetUnique(h->events[nevents]->any.jobId );
+ if (strcmp(id0,id) != 0) {
+ char et[BUFSIZ];
+ retval = EINVAL;
+ err.code = retval;
+ snprintf(et,sizeof et,"Attempt to process different jobs. Id '%s' (event n.%d) differs from '%s'",id,nevents+1,id0);
+ et[BUFSIZ-1] = 0;
+ err.desc = et;
+ err.source = "lb_plugin.c:edg_wlc_JobIdGetUnique()";
+ glite_jp_stack_error(ctx,&err);
+ goto fail;
+ }
+ }
+
+ if (id) free(id); id = NULL;
nevents++;
}
free(line);
}
cont:
- /* count state and status hiftory of the job given by the loaded events */
+ /* count state and status history of the job given by the loaded events */
if ((retval = lb_status(h)) != 0) goto fail;
*handle = (void *)h;
return 0;
fail:
+#ifdef PLUGIN_DEBUG
+ fprintf(stderr,"lb_plugin: open ERROR\n");
+#endif
for (i = 0; i < nevents; i++) {
edg_wll_FreeEvent(h->events[i]);
free(h->events[i]);
}
free(h->events);
free(buffer.buf);
+ if (id0) free(id0);
+ if (id) free(id);
edg_wll_FreeContext(context);
free(h);
*handle = NULL;
free (h->fullStatusHistory[i]);
i++;
}
+ h->fullStatusHistory = NULL;
+ h->lastStatusHistory = NULL;
+ h->finalStatus = NULL;
}
free(h);
strcmp(attr, GLITE_JP_LB_rQType) == 0 ||
strcmp(attr, GLITE_JP_LB_eDuration) == 0) {
/* have to be retrieved from JDL, but probably obsolete and not needed at all */
- char *et;
+ char et[BUFSIZ];
*attrval = NULL;
err.code = ENOSYS;
- trio_asprintf(&et,"Attribute '%s' not implemented yet.",attr);
- err.desc = strdup(et);
- free(et);
- free(ns);
+ snprintf(et,sizeof et,"Attribute '%s' not implemented yet.",attr);
+ et[BUFSIZ-1] = 0;
+ err.desc = et;
return glite_jp_stack_error(ctx,&err);
} else if (strcmp(attr, GLITE_JP_LB_RB) == 0) {
if (h->status.network_server) {
av[0].timestamp = h->status.lastUpdateTime.tv_sec;
}
} else if (strcmp(attr, GLITE_JP_LB_UIHost) == 0) {
- if (h->status.location) {
- av = calloc(2, sizeof(glite_jp_attrval_t));
- av[0].name = strdup(attr);
- av[0].value = strdup(h->status.location);
- av[0].size = -1;
- av[0].timestamp = h->status.lastUpdateTime.tv_sec;
- }
+ i = 0;
+ while (h->events[i]) {
+ if (h->events[i]->type == EDG_WLL_EVENT_REGJOB) {
+ if (h->events[i]->any.host) {
+ av = calloc(2, sizeof(glite_jp_attrval_t));
+ av[0].name = strdup(attr);
+ av[0].value = strdup(h->events[i]->any.host);
+ av[0].size = -1;
+ av[0].timestamp = h->events[i]->any.timestamp.tv_sec;
+ }
+ break;
+ }
+ i++;
+ }
} else if (strcmp(attr, GLITE_JP_LB_CPUTime) == 0) {
if (h->status.cpuTime) {
av = calloc(2, sizeof(glite_jp_attrval_t));
}
} else if (strcmp(attr, GLITE_JP_LB_NProc) == 0) {
/* currently LB hasn't got the info */
- char *et;
+ char et[BUFSIZ];
*attrval = NULL;
err.code = ENOSYS;
- trio_asprintf(&et,"Attribute '%s' not implemented yet.",attr);
- err.desc = strdup(et);
- free(et);
- free(ns);
+ snprintf(et,sizeof et,"Attribute '%s' not implemented yet.",attr);
+ et[BUFSIZ-1] = 0;
+ err.desc = et;
return glite_jp_stack_error(ctx,&err);
} else if (strcmp(attr, GLITE_JP_LB_finalStatus) == 0) {
av = calloc(2, sizeof(glite_jp_attrval_t));
av[0].name = strdup(attr);
- av[0].value = edg_wll_StatToString(h->status.state);
+ if (h->finalStatus) {
+ av[0].value = edg_wll_StatToString(h->finalStatus->state);
+ av[0].timestamp = h->finalStatus->timestamp.tv_sec;
+ } else {
+ av[0].value = edg_wll_StatToString(h->status.state);
+ av[0].timestamp = h->status.lastUpdateTime.tv_sec;
+ }
av[0].size = -1;
- av[0].timestamp = h->status.lastUpdateTime.tv_sec;
} else if (strcmp(attr, GLITE_JP_LB_finalStatusDate) == 0) {
struct tm *t = NULL;
- if ((t = gmtime(&h->status.lastUpdateTime.tv_sec)) != NULL) {
+ if ( (h->finalStatus) &&
+ ((t = gmtime(&h->finalStatus->timestamp.tv_sec)) != NULL) ) {
+ av = calloc(2, sizeof(glite_jp_attrval_t));
+ av[0].name = strdup(attr);
+ /* dateTime format: yyyy-mm-ddThh:mm:ss.uuuuuu */
+ trio_asprintf(&av[0].value,"%04d-%02d-%02dT%02d:%02d:%02d.%06d",
+ 1900+t->tm_year, 1+t->tm_mon, t->tm_mday,
+ t->tm_hour, t->tm_min, t->tm_sec,
+ h->finalStatus->timestamp.tv_usec);
+ av[0].size = -1;
+ av[0].timestamp = h->finalStatus->timestamp.tv_sec;
+ } else if ((t = gmtime(&h->status.lastUpdateTime.tv_sec)) != NULL) {
av = calloc(2, sizeof(glite_jp_attrval_t));
av[0].name = strdup(attr);
/* dateTime format: yyyy-mm-ddThh:mm:ss.uuuuuu */
av[0].timestamp = h->status.lastUpdateTime.tv_sec;
}
} else if (strcmp(attr, GLITE_JP_LB_finalStatusReason) == 0) {
- if (h->status.reason) {
+ if (h->finalStatus && h->finalStatus->reason) {
+ av = calloc(2, sizeof(glite_jp_attrval_t));
+ av[0].name = strdup(attr);
+ av[0].value = strdup(h->finalStatus->reason);
+ av[0].size = -1;
+ av[0].timestamp = h->finalStatus->timestamp.tv_sec;
+ } else if (h->status.reason) {
av = calloc(2, sizeof(glite_jp_attrval_t));
av[0].name = strdup(attr);
av[0].value = strdup(h->status.reason);
av[0].timestamp = h->status.lastUpdateTime.tv_sec;
}
} else if (strcmp(attr, GLITE_JP_LB_LRMSDoneStatus) == 0) {
+ i = 0;
+ j = -1;
+ while (h->events[i]) {
+ if ( (h->events[i]->type == EDG_WLL_EVENT_DONE) &&
+ (h->events[i]->any.source == EDG_WLL_SOURCE_LRMS) )
+ j = i;
+ i++;
+ }
av = calloc(2, sizeof(glite_jp_attrval_t));
av[0].name = strdup(attr);
- av[0].value = edg_wll_DoneStatus_codeToString(h->status.done_code);
av[0].size = -1;
- av[0].timestamp = h->status.lastUpdateTime.tv_sec;
+ if ( j != -1) {
+ av[0].value = edg_wll_DoneStatus_codeToString(h->events[j]->done.status_code);
+ av[0].timestamp = h->events[j]->any.timestamp.tv_sec;
+ } else {
+ av[0].value = edg_wll_DoneStatus_codeToString(h->status.done_code);
+ av[0].timestamp = h->status.lastUpdateTime.tv_sec;
+ }
} else if (strcmp(attr, GLITE_JP_LB_LRMSStatusReason) == 0) {
i = 0;
+ j = -1;
while (h->events[i]) {
- if (h->events[i]->type == EDG_WLL_EVENT_DONE) {
- if (h->events[i]->done.reason) {
- av = calloc(2, sizeof(glite_jp_attrval_t));
- av[0].name = strdup(attr);
- av[0].value = strdup(h->events[i]->done.reason);
- av[0].size = -1;
- av[0].timestamp = h->events[i]->any.timestamp.tv_sec;
- }
- break;
- }
+ if ( (h->events[i]->type == EDG_WLL_EVENT_DONE) &&
+ (h->events[i]->any.source == EDG_WLL_SOURCE_LRMS) )
+ j = i;
i++;
}
+ if ( ( j != -1) && (h->events[j]->done.reason) ) {
+ av = calloc(2, sizeof(glite_jp_attrval_t));
+ av[0].name = strdup(attr);
+ av[0].value = strdup(h->events[j]->done.reason);
+ av[0].size = -1;
+ av[0].timestamp = h->events[j]->any.timestamp.tv_sec;
+ }
} else if (strcmp(attr, GLITE_JP_LB_retryCount) == 0) {
av = calloc(2, sizeof(glite_jp_attrval_t));
av[0].name = strdup(attr);
av[0].timestamp = h->status.lastUpdateTime.tv_sec;
} else if (strcmp(attr, GLITE_JP_LB_additionalReason) == 0) {
/* what is it? */
- char *et;
+ char et[BUFSIZ];
*attrval = NULL;
err.code = ENOSYS;
- trio_asprintf(&et,"Attribute '%s' not implemented yet.",attr);
- err.desc = strdup(et);
- free(et);
- free(ns);
+ snprintf(et,sizeof et,"Attribute '%s' not implemented yet.",attr);
+ et[BUFSIZ-1] = 0;
+ err.desc = et;
return glite_jp_stack_error(ctx,&err);
} else if (strcmp(attr, GLITE_JP_LB_jobType) == 0) {
av = calloc(2, sizeof(glite_jp_attrval_t));
old_val = strdup ("");
for (i=0; i<h->status.children_num; i++) {
trio_asprintf(&val,"%s\t\t<jobId>%s</jobId>\n",
- old_val, "");
-// FIXME: h->status.children[i] ? h->status.children[i] : "");
+ old_val, h->status.children[i] ? h->status.children[i] : "");
if (old_val) free(old_val);
old_val = val; val = NULL;
}
av[0].size = -1;
av[0].timestamp = h->status.lastUpdateTime.tv_sec;
} else {
- char *et;
+ char et[BUFSIZ];
*attrval = NULL;
err.code = ENOENT;
- trio_asprintf(&et,"Value unknown for attribute '%s', there are no subjobs.",attr);
- err.desc = strdup(et);
- free(et);
- free(ns);
+ snprintf(et,sizeof et,"Value unknown for attribute '%s', there are no subjobs.",attr);
+ et[BUFSIZ-1] = 0;
+ err.desc = et;
return glite_jp_stack_error(ctx,&err);
}
} else if (strcmp(attr, GLITE_JP_LB_lastStatusHistory) == 0) {
}
}
} else if (strcmp(attr, GLITE_JP_LB_JDL) == 0) {
- i = 0;
- while (h->events[i]) {
- if ((h->events[i]->type == EDG_WLL_EVENT_REGJOB) &&
- (h->events[i]->regJob.jdl) ) {
- av = calloc(2, sizeof(glite_jp_attrval_t));
- av[0].name = strdup(attr);
- av[0].value = strdup(h->events[i]->regJob.jdl);
- av[0].timestamp = h->events[i]->any.timestamp.tv_sec;
- av[0].size = -1;
- break;
- }
- i++;
+ if (h->status.jdl) {
+ av = calloc(2, sizeof(glite_jp_attrval_t));
+ av[0].name = strdup(attr);
+ av[0].value = strdup(h->status.jdl);
+ av[0].size = -1;
+ av[0].timestamp = h->status.lastUpdateTime.tv_sec;
}
} else {
- char *et;
+ char et[BUFSIZ];
*attrval = NULL;
err.code = EINVAL;
- trio_asprintf(&et,"No such attribute '%s'.",attr);
- err.desc = strdup(et);
- free(et);
- free(ns);
+ snprintf(et,sizeof et,"No such attribute '%s'.",attr);
+ et[BUFSIZ-1] = 0;
+ err.desc = et;
return glite_jp_stack_error(ctx,&err);
}
*attrval = av;
return 0;
} else {
- char *et;
+ char et[BUFSIZ];
*attrval = NULL;
err.code = ENOENT;
- trio_asprintf(&et,"Value unknown for attribute '%s'.",attr);
- err.desc = strdup(et);
- free(et);
+ snprintf(et,sizeof et,"Value unknown for attribute '%s'.",attr);
+ et[BUFSIZ-1] = 0;
+ err.desc = et;
if (av) glite_jp_attrval_free(av,1); // XXX: probably not needed
return glite_jp_stack_error(ctx,&err);
}
lb_handle *h = (lb_handle *) handle;
intJobStat *js;
- int maxnstates, nstates, i, be_strict = 0;
+ int maxnstates, nstates, i, be_strict = 0, retval;
char *errstring;
edg_wll_JobStatCode old_state = EDG_WLL_JOB_UNDEF;
nstates = 0;
h->fullStatusHistory = calloc(maxnstates, sizeof(lb_historyStatus *));
h->lastStatusHistory = NULL;
+ h->finalStatus = NULL;
i = 0;
while (h->events[i])
{
h->fullStatusHistory[nstates]->timestamp.tv_sec = js->pub.stateEnterTime.tv_sec;
h->fullStatusHistory[nstates]->timestamp.tv_usec = js->pub.stateEnterTime.tv_usec;
h->fullStatusHistory[nstates]->reason = check_strdup(js->pub.reason);
+ /* lastStatusHistory starts from the last WAITING state */
if (js->pub.state == EDG_WLL_JOB_WAITING) {
h->lastStatusHistory = &(h->fullStatusHistory[nstates]);
}
+ /* finalStatus is the one preceeding the CLEARED state */
+ if ( (js->pub.state == EDG_WLL_JOB_CLEARED) && (nstates > 0) ) {
+ h->finalStatus = h->fullStatusHistory[nstates-1];
+ }
old_state = js->pub.state;
nstates++;
}
i++;
}
h->fullStatusHistory[nstates] = NULL;
+ /* if there is no CLEARED state, finalStatus is just the last status
+ and if there is no such thing, leave h->finalStatus NULL and for the attribute
+ try to read something from the h->status */
+ if ( (h->finalStatus == NULL) && (nstates > 0) ) {
+ h->finalStatus = h->fullStatusHistory[nstates-1];
+ }
+
+ /* fill in also subjobs */
+ if (js->pub.children_num > 0) {
+ edg_wll_Context context;
+ edg_wlc_JobId *subjobs;
+
+ if ((retval = edg_wll_InitContext(&context)) != 0) return retval;
+ subjobs = calloc(js->pub.children_num, sizeof (*subjobs));
+ if ((retval = edg_wll_GenerateSubjobIds(context,
+ js->pub.jobId, js->pub.children_num, js->pub.seed, &subjobs) ) != 0 ) {
+ goto err;
+ }
+ js->pub.children = calloc(js->pub.children_num + 1, sizeof (*js->pub.children));
+ for (i=0; i<js->pub.children_num; i++) {
+ js->pub.children[i] = edg_wlc_JobIdUnparse(subjobs[i]);
+ }
+ edg_wll_FreeContext(context);
+ free(subjobs);
+ }
memcpy(&h->status, &js->pub, sizeof(edg_wll_JobStat));
edg_wll_FreeStmt(&sh);
} while ( limit_loop );
- if ( eperm && !*jobs_out )
- edg_wll_SetError(ctx, EPERM, "matching jobs found but authorization failed");
+ if ( !*jobs_out ) {
+ if (eperm) edg_wll_SetError(ctx, EPERM, "matching jobs found but authorization failed");
+ else edg_wll_SetError(ctx, ENOENT, "no matching jobs found");
+ }
if ( i && (ret == 0) )
{
#include "glite/lb/context-int.h"
#include "soap_version.h"
+#include "glite/security/glite_gscompat.h"
#include "bk_ws_H.h"
#include "bk_ws_Stub.h"
+#if GSOAP_VERSION >= 20709
+ #define GFITEM reason
+ #define GFNUM SOAP_TYPE_lbt__genericFault
+#else
+ #define GFITEM lbe__genericFault
+ #define GFNUM SOAP_TYPE__genericFault
+#endif
+
+
void edg_wll_ErrToFault(const edg_wll_Context ctx,struct soap *soap)
{
char *et,*ed;
struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail);
+#if GSOAP_VERSION >= 20709
+ struct lbt__genericFault *f = soap_malloc(soap,sizeof *f);
+#else
struct _genericFault *f = soap_malloc(soap,sizeof *f);
+#endif
+ f->GFITEM = soap_malloc(soap,sizeof *f->GFITEM);
+ memset(f->GFITEM, 0, sizeof(*f->GFITEM));
- f->lbe__genericFault = soap_malloc(soap,sizeof *f->lbe__genericFault);
- memset(f->lbe__genericFault, 0, sizeof(*f->lbe__genericFault));
-
- f->lbe__genericFault->code = edg_wll_Error(ctx,&et,&ed);
- f->lbe__genericFault->text = soap_malloc(soap,strlen(et)+1);
- strcpy(f->lbe__genericFault->text,et);
+ f->GFITEM->code = edg_wll_Error(ctx,&et,&ed);
+ f->GFITEM->text = soap_malloc(soap,strlen(et)+1);
+ strcpy(f->GFITEM->text,et);
free(et);
if (ed) {
- f->lbe__genericFault->description = soap_malloc(soap,strlen(ed)+1);
- strcpy(f->lbe__genericFault->description,ed);
+ f->GFITEM->description = soap_malloc(soap,strlen(ed)+1);
+ strcpy(f->GFITEM->description,ed);
free(ed);
}
- detail->__type = SOAP_TYPE__genericFault;
+ detail->__type = GFNUM;
#if GSOAP_VERSION >= 20700
detail->fault = f;
#else
void edg_wll_FaultToErr(const struct soap *soap,edg_wll_Context ctx)
{
- struct SOAP_ENV__Detail *detail = soap->version == 2 ?
- soap->fault->SOAP_ENV__Detail : soap->fault->detail;
-
+ struct SOAP_ENV__Detail *detail;
struct lbt__genericFault *f;
- if (detail->__type == SOAP_TYPE__genericFault) {
-#if GSOAP_VERSION >= 20700
+ if (!soap->fault) {
+ edg_wll_SetError(ctx,EINVAL,"SOAP: (no error info)");
+ return;
+ }
+
+ detail = soap->version == 2 ? soap->fault->SOAP_ENV__Detail : soap->fault->detail;
+ if (detail->__type == GFNUM) {
+#if GSOAP_VERSION >= 20709
+ f = detail->lbe__genericFault;
+#elif GSOAP_VERSION >= 20700
f = ((struct _genericFault *) detail->fault)
->lbe__genericFault;
#else
char *s;
asprintf(&s,"SOAP: %s", soap->version == 2 ?
- soap->fault->SOAP_ENV__Reason : soap->fault->faultstring);
+ GLITE_SECURITY_GSOAP_REASON(soap) : soap->fault->faultstring);
edg_wll_SetError(ctx,EINVAL,s);
free(s);
}
#include <stdsoap2.h>
-#include "glite/security/glite_gsplugin.h"
-
#include "glite/lb/context-int.h"
#include "glite/lb/consumer.h"
+#include "soap_version.h"
+#include "glite/security/glite_gsplugin.h"
+#include "glite/security/glite_gscompat.h"
+
#include "jobstat.h"
#include "query.h"
#include "bk_ws_H.h"
#include "ws_fault.h"
#include "ws_typeref.h"
-#include "soap_version.h"
-
#if GSOAP_VERSION <= 20602
#define __lb__GetVersion __ns1__GetVersion
#define __lb__JobStatus __ns1__JobStatus
return SOAP_FAULT;
}
- edg_wll_StatusToSoap(soap, &s, &(out->stat));
+ out->stat = soap_malloc(soap, sizeof(*out->stat));
+ edg_wll_StatusToSoap(soap, &s, out->stat);
return SOAP_OK;
}
#include "glite/lb/consumer.h"
/* XXX: references only, src and dest share pointers */
+#include "glite/security/glite_gscompat.h"
+
+#define VALUEEV_GET(X, V) GLITE_SECURITY_GSOAP_CHOICE_GET((X), V, event, 1)
+#define VALUEEV_SET(X, V, VALUE) GLITE_SECURITY_GSOAP_CHOICE_SET((X), V, lbt, event, 1, VALUE)
+#define VALUEEV_ISTYPE(X, V) GLITE_SECURITY_GSOAP_CHOICE_ISTYPE((X), V, lbt, event, 1)
+#define VALUEQR_GET(X, V) GLITE_SECURITY_GSOAP_CHOICE_GET((X), V, queryRecValue, 2)
+#define VALUEQR_SETTYPE(X, V) GLITE_SECURITY_GSOAP_CHOICE_SETTYPE((X), V, lbt, queryRecValue, 2)
+#define VALUEQR_SET(X, V, VALUE) GLITE_SECURITY_GSOAP_CHOICE_SET((X), V, lbt, queryRecValue, 2, VALUE)
+#define VALUEQR_ISTYPE(X, V) GLITE_SECURITY_GSOAP_CHOICE_ISTYPE((X), V, lbt, queryRecValue, 2)
+
@@@{
#
# generate the command for move native data to soap web services structures
$soap_fn = $1.ucfirst($2);
};
$source = "$src->$native_en.$native_fn";
- $dest = "$dst->$soap_en->$soap_fn";
+ $dest = "VALUEEV_GET($dst, $soap_en)->$soap_fn";
# print STDERR "$src, $dst, $soap_en, $soap_fn, $native_fn, $tn, $usuc\n";
if ($tn eq 'int') {
} elsif ($tn eq 'string' || $tn eq 'notifid') {
gen $indent."$dest = soap_strdup(soap, $source);\n";
} elsif ($tn eq 'jobstat') {
- gen $indent."edg_wll_StatusToSoap(soap, $source, &$dest);\n";
+ gen $indent."$dest = soap_malloc(soap, sizeof(struct lbt__jobStatus))";
+ gen $indent."edg_wll_StatusToSoap(soap, $source, $dest);\n";
} elsif ($tn eq 'timeval') {
gen $indent."$dest = soap_malloc(soap, sizeof(struct lbt__timeval));\n";
gen $indent."$dest->tvSec = $source.tv_sec;\n";
while ($soap_fn =~ /([[:alpha:]]*)_([[:alpha:]_]*)/) {
$soap_fn = $1.ucfirst($2);
};
- $dest = "$dst->$soap_en->$soap_fn";
+ $dest = "VALUEEV_GET($dst, $soap_en)->$soap_fn";
if ($tn eq 'int' || $tn eq 'port' || $tn eq 'bool' || $tn eq 'logsrc') {
if ($f->{optional}) {
}
}
-int edg_wll_StatusToSoap(struct soap *soap,edg_wll_JobStat const *src,struct lbt__jobStatus **dest)
+int edg_wll_StatusToSoap(struct soap *soap,edg_wll_JobStat const *src,struct lbt__jobStatus *js)
{
int i,j;
char *s;
- struct lbt__jobStatus *js;
- if ( !(js = soap_malloc(soap, sizeof(*js))) ) return SOAP_FAULT;
memset(js, 0, sizeof(*js));
edg_wll_JobStatCodeToSoap(src->state, &(js->state));
@@@{
gen qq{
! /* XXX: don't count UNDEF */
! if (src->$_) {
-! struct lbt__${usuc}Item **h = soap_malloc(soap,sizeof *h * (EDG_WLL_NUMBER_OF_STATCODES-1));
-! js->__size$usuc = EDG_WLL_NUMBER_OF_STATCODES-1;
+! GLITE_SECURITY_GSOAP_LIST_TYPE(lbt, ${usuc}Item) h;
+!
+! GLITE_SECURITY_GSOAP_LIST_CREATE(soap, js, ${usuc}, struct lbt__${usuc}Item, EDG_WLL_NUMBER_OF_STATCODES-1);
+! h = js->${usuc};
! for (i=1; i<EDG_WLL_NUMBER_OF_STATCODES; i++) {
-! h[i-1] = soap_malloc(soap, sizeof **h);
-! edg_wll_JobStatCodeToSoap(i,&h[i-1]->state);
-! h[i-1]->$fmap{$_} = src->$_\[i];
+! edg_wll_JobStatCodeToSoap(i,&GLITE_SECURITY_GSOAP_LIST_GET(h, i-1)->state);
+! GLITE_SECURITY_GSOAP_LIST_GET(h, i-1)->$fmap{$_} = src->$_\[i];
! }
-! js->$usuc = h;
! }
! else {
! js->__size$usuc = 0;
} elsif ($ft eq 'taglist') {
gen qq{
! {
-! struct lbt__tagValue *t,**tl = NULL;
+! struct lbt__tagValue *t;
+!
+! for (i=0; src->$_ && src->$_\[i].tag; i++);
+! GLITE_SECURITY_GSOAP_LIST_CREATE(soap, js, $usuc, struct lbt__tagValue, i);
! for (i=0; src->$_ && src->$_\[i].tag; i++) {
-! t = soap_malloc(soap,sizeof *t);
-! tl = realloc(tl,(i+1) * sizeof *tl);
+! t = GLITE_SECURITY_GSOAP_LIST_GET(js->$usuc, i);
! t->tag = soap_strdup(soap,src->$_\[i].tag);
! t->value = soap_strdup(soap,src->$_\[i].value);
-! tl[i] = t;
! }
-! js->__size$usuc = i;
-! if (i) {
-! js->$usuc = soap_malloc(soap,i * sizeof *tl);
-! memcpy(js->$usuc,tl,i * sizeof *tl);
-! free(tl);
-! } else js->$usuc = NULL;
! }
};
} elsif ($ft eq 'stslist') {
gen qq{
! for (i=0; src->$_ && src->$_\[i].state; i++);
-! if ((js->__size$usuc = i)) {
-! js->$usuc = soap_malloc(soap,i * sizeof *js->$usuc);
-! for (j=0; j<i; i++) edg_wll_StatusToSoap(soap,src->$_+j,&js->$usuc\[j]);
-! }
-! else js->$usuc = NULL;
+! GLITE_SECURITY_GSOAP_LIST_CREATE(soap, js, $usuc, struct lbt__jobStatus, i);
+! for (j=0; j<i; j++) edg_wll_StatusToSoap(soap,src->$_+j,GLITE_SECURITY_GSOAP_LIST_GET(js->$usuc, j));
};
} elsif ($ft eq 'timeval') {
gen "\tjs->$usuc = soap_malloc(soap,sizeof *js->$usuc);\n";
}
@@@}
- *dest = js;
return SOAP_OK;
}
! dest->$_\[0] = src->__size$usuc;
! for (i=0; i<src->__size$usuc; i++) {
! edg_wll_JobStatCode s;
-! edg_wll_SoapToJobStatCode(src->$usuc\[i]->state,&s);
+! edg_wll_SoapToJobStatCode(GLITE_SECURITY_GSOAP_LIST_GET(src->$usuc, i)->state,&s);
! assert(s>=0); assert(s<EDG_WLL_NUMBER_OF_STATCODES);
-! dest->$_\[s+1] = src->$usuc\[i]->$fmap{$_};
+! dest->$_\[s+1] = GLITE_SECURITY_GSOAP_LIST_GET(src->$usuc, i)->$fmap{$_};
! }
! }
! else dest->$_ = NULL;
gen qq{
! if (src->__size$usuc) {
! dest->$_ = calloc(src->__size$usuc + 1,sizeof *dest->$_);
-! for (i=0; i<src->__size$usuc; i++) edg_wll_SoapToStatus(soap,src->$usuc\[i],dest->$_ + i);
+! for (i=0; i<src->__size$usuc; i++) edg_wll_SoapToStatus(soap,GLITE_SECURITY_GSOAP_LIST_GET(src->$usuc, i),dest->$_ + i);
! }
! else dest->$_ = NULL;
};
if (src->__size$usuc) {
dest->$_ = calloc(src->__size$usuc + 1,sizeof *dest->$_);
for (i=0; i<src->__size$usuc; i++) {
- soap_unlink(soap,dest->$_\[i].tag = src->$usuc\[i]->tag);
- soap_unlink(soap,dest->$_\[i].tag = src->$usuc\[i]->tag);
+ soap_unlink(soap,dest->$_\[i].tag = GLITE_SECURITY_GSOAP_LIST_GET(src->$usuc, i)->tag);
+ soap_unlink(soap,dest->$_\[i].tag = GLITE_SECURITY_GSOAP_LIST_GET(src->$usuc, i)->tag);
}
}
else dest->$_ = NULL;
union edg_wll_QueryVal *out)
{
assert(in); assert(out);
- if ( in->c ) {
+ if ( VALUEQR_ISTYPE(in, c) ) {
if ( attr == EDG_WLL_QUERY_ATTR_JOBID || attr == EDG_WLL_QUERY_ATTR_PARENT ) {
- if ( edg_wlc_JobIdParse(in->c, &(out->j)) ) return -1;
+ if ( edg_wlc_JobIdParse(VALUEQR_GET(in, c), &(out->j)) ) return -1;
} else {
- if ( !(out->c = strdup(in->c)) ) return -1;
+ if ( !(out->c = strdup(VALUEQR_GET(in, c))) ) return -1;
}
}
- else if ( in->t ) {
- out->t.tv_sec = in->t->tvSec;
- out->t.tv_usec = in->t->tvUsec;
+ else if ( VALUEQR_ISTYPE(in, t) ) {
+ out->t.tv_sec = VALUEQR_GET(in, t)->tvSec;
+ out->t.tv_usec = VALUEQR_GET(in, t)->tvUsec;
}
- else if ( in->i ) out->i = *(in->i);
+ else if ( VALUEQR_ISTYPE(in, i) ) out->i = *(VALUEQR_GET(in, i));
return 0;
}
case EDG_WLL_QUERY_ATTR_DESTINATION:
case EDG_WLL_QUERY_ATTR_HOST:
case EDG_WLL_QUERY_ATTR_INSTANCE:
- if ( in->c && !(out->c = soap_strdup(soap, in->c)) ) return SOAP_FAULT;
+ VALUEQR_SET(out, c, in->c ? soap_strdup(soap, in->c) : NULL);
+ if (in->c && !VALUEQR_GET(out, c) ) return SOAP_FAULT;
break;
case EDG_WLL_QUERY_ATTR_JOBID:
case EDG_WLL_QUERY_ATTR_PARENT: {
char *s = edg_wlc_JobIdUnparse(in->j);
- out->c = soap_strdup(soap, s);
+ VALUEQR_SET(out, c, soap_strdup(soap, s));
free(s);
- if ( !out->c ) return SOAP_FAULT;
+ if ( !VALUEQR_GET(out, c) ) return SOAP_FAULT;
}
break;
case EDG_WLL_QUERY_ATTR_TIME:
- out->t = soap_malloc(soap, sizeof(*(out->t)));
- if ( !out->t ) return SOAP_FAULT;
- out->t->tvSec = in->t.tv_sec;
- out->t->tvUsec = in->t.tv_usec;
+ VALUEQR_SET(out, t, soap_malloc(soap, sizeof(*(VALUEQR_GET(out, t)))));
+ if ( !VALUEQR_GET(out, t) ) return SOAP_FAULT;
+ VALUEQR_SETTYPE(out, t);
+ VALUEQR_GET(out, t)->tvSec = in->t.tv_sec;
+ VALUEQR_GET(out, t)->tvUsec = in->t.tv_usec;
break;
case EDG_WLL_QUERY_ATTR_STATUS:
case EDG_WLL_QUERY_ATTR_DONECODE:
case EDG_WLL_QUERY_ATTR_EVENT_TYPE:
case EDG_WLL_QUERY_ATTR_RESUBMITTED:
default:
- out->i = soap_malloc(soap, sizeof(*(out->i)));
- if ( !out->i ) return SOAP_FAULT;
- *(out->i) = in->i;
+ VALUEQR_SET(out, i, soap_malloc(soap, sizeof(*(VALUEQR_GET(out, i)))));
+ if ( !VALUEQR_GET(out, i) ) return SOAP_FAULT;
+ *(VALUEQR_GET(out, i)) = in->i;
break;
}
int edg_wll_QueryRecToSoap(
struct soap *soap,
const edg_wll_QueryRec *in,
- struct lbt__queryRecord **out)
+ struct lbt__queryRecord *qr)
{
- struct lbt__queryRecord *qr;
-
-
- assert(in); assert(out);
- if ( !(qr = soap_malloc(soap, sizeof(*qr))) ) return SOAP_FAULT;
+ assert(in); assert(qr);
memset(qr, 0, sizeof(*qr));
if ( !in ) goto ret;
edg_wll_QueryOpToSoap(in->op, &(qr->op));
}
ret:
- *out = qr;
return SOAP_OK;
}
assert(in); assert(out);
if ( !(qr = calloc(in->__sizerecord+1, sizeof(*qr))) ) goto err;
for ( i = 0; i < in->__sizerecord; i++ )
- if ( edg_wll_SoapToQueryRec(in, in->record[i], qr+i) ) goto err;
+ if ( edg_wll_SoapToQueryRec(in, GLITE_SECURITY_GSOAP_LIST_GET(in->record, i), qr+i) ) goto err;
*out = qr;
return 0;
int edg_wll_QueryCondsToSoap(
struct soap *soap,
const edg_wll_QueryRec *in,
- struct lbt__queryConditions **out)
+ struct lbt__queryConditions *qc)
{
int i;
- struct lbt__queryConditions *qc;
- assert(out);
- if ( !(qc = soap_malloc(soap, sizeof(*qc))) )
- return SOAP_FAULT;
+ assert(qc);
memset(qc, 0, sizeof(*qc));
if ( !in )
goto ret;
if ( !qc->tagName ) return SOAP_FAULT;
}
- qc->__sizerecord = 0;
- while ( in[qc->__sizerecord].attr ) qc->__sizerecord++;
+ i = 0;
+ while ( in[i].attr ) i++;
- if ( !qc->__sizerecord )
+ if ( !i )
goto ret;
- qc->record = soap_malloc(soap, sizeof(*(qc->record)) * qc->__sizerecord);
+ GLITE_SECURITY_GSOAP_LIST_CREATE(soap, qc, record, struct lbt__queryRecord, i);
if ( !qc->record )
return SOAP_FAULT;
for ( i = 0; in[i].attr; i++ )
- if ( edg_wll_QueryRecToSoap(soap, &in[i], &(qc->record[i])) )
+ if ( edg_wll_QueryRecToSoap(soap, &in[i], GLITE_SECURITY_GSOAP_LIST_GET(qc->record, i)) )
return SOAP_FAULT;
ret:
- *out = qc;
return SOAP_OK;
}
* \param IN in array of soap query condition
* \param OUT out target array of queryRec
*/
-int edg_wll_SoapToQueryCondsExt(const struct lbt__queryConditions **in, int __sizecondition, edg_wll_QueryRec ***out)
+int edg_wll_SoapToQueryCondsExt(GLITE_SECURITY_GSOAP_LIST_TYPE(lbt, queryConditions) in, int __sizecondition, edg_wll_QueryRec ***out)
{
int i;
edg_wll_QueryRec **qr;
assert(out);
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;
+ if ( edg_wll_SoapToQueryConds(GLITE_SECURITY_GSOAP_LIST_GET(in, i), qr+i) ) goto err;
*out = qr;
return 0;
struct soap *soap,
const edg_wll_QueryRec **in,
int *out_size,
- struct lbt__queryConditions ***out)
+ GLITE_SECURITY_GSOAP_LIST_TYPE(lbt, queryConditions) *out)
{
int i, size;
- struct lbt__queryConditions **qc;
-
-
+ GLITE_SECURITY_GSOAP_LIST_TYPE(lbt, queryConditions) qc;
assert(in); assert(out);
size = 0;
if ( !size )
goto ret;
-
- qc = soap_malloc(soap, sizeof(*qc) * size);
+ GLITE_SECURITY_GSOAP_LIST_CREATE0(soap, qc, size, struct lbt__queryConditions, size);
if ( !qc ) return SOAP_FAULT;
for ( i = 0; in[i]; i++ )
- if ( edg_wll_QueryCondsToSoap(soap, in[i], &qc[i]) )
+ if ( edg_wll_QueryCondsToSoap(soap, in[i], GLITE_SECURITY_GSOAP_LIST_GET(qc, i)) )
return SOAP_FAULT;
ret:
}
if ( states ) {
for ( i = 0; states[i].state; i++ ) ;
- out->states = soap_malloc(soap, sizeof(*(out->states))*i);
+ GLITE_SECURITY_GSOAP_LIST_CREATE(soap, out, states, struct lbt__jobStatus, i);
if ( !out->states ) return SOAP_FAULT;
- out->__sizestates = i;
for ( i = 0; states[i].state; i++ )
- if ( edg_wll_StatusToSoap(soap, states+i, out->states+i) )
+ if ( edg_wll_StatusToSoap(soap, states+i, GLITE_SECURITY_GSOAP_LIST_GET(out->states, i)) )
return SOAP_FAULT;
}
* \param IN event source event
* \param OUT sevent target Soap event
*/
-int edg_wll_EventToSoap(struct soap* soap, const edg_wll_Event *event, struct lbt__event **sevent) {
+int edg_wll_EventToSoap(struct soap* soap, const edg_wll_Event *event, struct lbt__event *sevent) {
char *s;
- *sevent = soap_malloc(soap, sizeof(**sevent));
- memset(*sevent, 0, sizeof(**sevent));
- if (!*sevent) return 0;
-
switch (event->any.type) {
@@@{
my ($soap_en);
};
gen qq {
! case EDG_WLL_EVENT_$u:
-! (*sevent)->$soap_en = soap_malloc(soap, sizeof(struct lbt__event$soap_en));
+! VALUEEV_SET(sevent, $soap_en, soap_malloc(soap, sizeof(struct lbt__event$soap_en)));
};
selectType $event '_common_';
for (getFieldsOrdered $event) {
my ($f);
$f = selectField $event $_;
- eventFieldAssign("\t\t\t", "event", "(*sevent)", $e, $f, 1);
+ eventFieldAssign("\t\t\t", "event", "sevent", $e, $f, 1);
}
gen "\n";
my ($f);
$f = selectField $event $_;
- eventFieldAssign("\t\t\t", "event", "(*sevent)", $e, $f, 0);
+ eventFieldAssign("\t\t\t", "event", "sevent", $e, $f, 0);
}
gen qq {
! break;
$soap_en = $e;
$soap_en = $1.ucfirst $2 while $soap_en =~ /([[:alpha:]]*)_([[:alpha:]_]*)/;
- gen "\tif (sevent->$soap_en) {\n";
+ gen "\tif (VALUEEV_ISTYPE(sevent, $soap_en)) {\n";
selectType $event '_common_';
for (getFieldsOrdered $event) {
$f = selectField $event $_;
eventFieldFree("\t\t", "sevent", $e, $f);
}
- gen qq "\t\tsoap_dealloc(soap, sevent->$soap_en);\n";
+ gen qq "\t\tsoap_dealloc(soap, VALUEEV_GET(sevent, $soap_en));\n";
gen qq "\t}\n";
}
@@@}
+ // XXX: element dealocation belongs to higher layer
+#if GSOAP_VERSION <= 20706
soap_dealloc(soap, sevent);
+#endif
}
const edg_wll_Event *events,
struct _lbe__QueryEventsResponse *out)
{
- int memsize, i;
+ int i;
struct lbt__event *event;
/* alloc the events array */
memset(out, 0, sizeof(*out));
for (out->__sizeevents = 0; events[out->__sizeevents].any.type != EDG_WLL_EVENT_UNDEF; out->__sizeevents++);
if (!out->__sizeevents) return SOAP_OK;
- memsize = out->__sizeevents * sizeof(*out->events);
- out->events = soap_malloc(soap, memsize);
- memset(out->events, 0, memsize);
+ GLITE_SECURITY_GSOAP_LIST_CREATE(soap, out, events, struct lbt__event, out->__sizeevents);
+ for (i = 0; i < out->__sizeevents; i++)
+ memset(GLITE_SECURITY_GSOAP_LIST_GET(out->events, i), 0, sizeof(struct lbt__event));
if (!out->events) return SOAP_FAULT;
for (i = 0; i < out->__sizeevents; i++) {
- if (!edg_wll_EventToSoap(soap, &events[i], &out->events[i])) goto err;
+ if (!edg_wll_EventToSoap(soap, &events[i], GLITE_SECURITY_GSOAP_LIST_GET(out->events, i))) goto err;
}
return SOAP_OK;
err:
- event = out->events[0];
+ event = GLITE_SECURITY_GSOAP_LIST_GET(out->events, 0);
while (event) {
edg_wll_FreeSoapEvent(soap, event);
event++;
}
+ /*
+ * XXX: better list destroy here w/o deallocstion in
+ * edg_wll_FreeSoapEvent
+ */
soap_dealloc(soap, out->events);
return SOAP_FAULT;
{
my $comment = getTypeComment $event $name;
$name = $1.ucfirst $2 while $name =~ /([[:alpha:]]*)_([[:alpha:]_]*)/;
- gen "\t\tif (in->$name) {\n";
+ gen "\t\tif (VALUEEV_ISTYPE(in, $name)) {\n";
my $event_type = uc $name;
gen "\t\t\tout->type = EDG_WLL_EVENT_$event_type;\n";
$usuc = $1.uc($2).$3 while ($usuc =~ /([^_]*)_([a-z])(.*)/);
my $fuc = ucfirst($usuc);
+ my $src = "VALUEEV_GET(in, $name)->$usuc";
if ($ft eq 'jobid') {
- gen "\t\t\tif (in->$name->$usuc)\n";
- gen "\t\t\t\tedg_wlc_JobIdParse(in->$name->$usuc,&out->$act.$fn);\n";
+ gen "\t\t\tif ($src)\n";
+ gen "\t\t\t\tedg_wlc_JobIdParse($src,&out->$act.$fn);\n";
} elsif ($ft eq 'timeval') {
- gen "\t\t\tout->$act.$fn.tv_sec = in->$name->$usuc->tvSec;\n";
- gen "\t\t\tout->$act.$fn.tv_usec = in->$name->$usuc->tvUsec;\n";
+ gen "\t\t\tout->$act.$fn.tv_sec = $src->tvSec;\n";
+ gen "\t\t\tout->$act.$fn.tv_usec = $src->tvUsec;\n";
} elsif ($ft eq 'string') {
- gen "\t\t\tout->$act.$fn = in->$name->$usuc;\n";
- gen "\t\t\tsoap_unlink(soap,in->$name->$usuc);\n";
+ gen "\t\t\tout->$act.$fn = $src;\n";
+ gen "\t\t\tsoap_unlink(soap,$src);\n";
} elsif ($ft eq 'int') {
if ($f->{codes}) {
if ($type eq '_common_') {
- gen "\t\t\tedg_wll_SoapTo$fuc(in->$name->$usuc,&(out->$act.$fn));\n";
+ gen "\t\t\tedg_wll_SoapTo$fuc($src,&(out->$act.$fn));\n";
}
else {
- gen "\t\t\tedg_wll_SoapTo$name$fuc(in->$name->$usuc,&(out->$act.$fn));\n";
+ gen "\t\t\tedg_wll_SoapTo$name$fuc($src,&(out->$act.$fn));\n";
}
}
elsif ($f->{optional}) {
- gen "\t\t\tout->$act.$fn = *in->$name->$usuc;\n";
+ gen "\t\t\tout->$act.$fn = *$src;\n";
}
else {
- gen "\t\t\tout->$act.$fn = in->$name->$usuc;\n";
+ gen "\t\t\tout->$act.$fn = $src;\n";
}
}
elsif ($ft eq 'logsrc') {
- gen "\t\t\tedg_wll_SoapToSource(in->$name->$usuc, &(out->$act.$fn));\n";
+ gen "\t\t\tedg_wll_SoapToSource($src, &(out->$act.$fn));\n";
}
else {
- gen "\t\t\tout->$act.$fn = in->$name->$usuc;\n";
+ gen "\t\t\tout->$act.$fn = $src;\n";
}
}
}
if (!events) return SOAP_FAULT;
for (i=0; i < in.__sizeevents; i++) {
- if (edg_wll_SoapToEvent(soap, in.events[i], &events[i]) != SOAP_OK) {
+ if (edg_wll_SoapToEvent(soap, GLITE_SECURITY_GSOAP_LIST_GET(in.events, i), &events[i]) != SOAP_OK) {
free_events(events);
return SOAP_FAULT;
}
extern void edg_wll_JobStatCodeToSoap(edg_wll_JobStatCode, enum lbt__statName *);
extern void edg_wll_SoapToJobStatCode(enum lbt__statName, edg_wll_JobStatCode *);
-extern void edg_wll_StatusToSoap(struct soap *, edg_wll_JobStat const *, struct lbt__jobStatus **);
+extern void edg_wll_StatusToSoap(struct soap *, edg_wll_JobStat const *, struct lbt__jobStatus *);
extern void edg_wll_SoapToStatus(struct soap *, struct lbt__jobStatus const *, edg_wll_JobStat *);
extern void edg_wll_SoapToJobStatFlags(struct lbt__jobFlags const *, int *);
edg_wll_QueryRec *out);
extern int edg_wll_QueryRecToSoap(struct soap *,
const edg_wll_QueryRec *,
- struct lbt__queryRecord **);
+ struct lbt__queryRecord *);
extern int edg_wll_SoapToQueryConds(
edg_wll_QueryRec **);
extern int edg_wll_QueryCondsToSoap(struct soap *,
const edg_wll_QueryRec *,
- struct lbt__queryConditions **);
+ struct lbt__queryConditions *);
extern int edg_wll_SoapToQueryCondsExt(
- const struct lbt__queryConditions **,
+ GLITE_SECURITY_GSOAP_LIST_TYPE(lbt, queryConditions) in,
int __sizecondition,
edg_wll_QueryRec ***);
extern int edg_wll_QueryCondsExtToSoap(struct soap *,
const edg_wll_QueryRec **,
int *,
- struct lbt__queryConditions ***);
+ GLITE_SECURITY_GSOAP_LIST_TYPE(lbt, queryConditions) *);
extern int edg_wll_JobsQueryResToSoap(struct soap *,
edg_wlc_JobId *,
edg_wll_Event **);
-extern int edg_wll_EventToSoap(struct soap*, const edg_wll_Event *, struct lbt__event **);
+extern int edg_wll_EventToSoap(struct soap*, const edg_wll_Event *, struct lbt__event *);
extern void edg_wll_FreeSoapEvent(struct soap *, struct lbt__event *);
#ifdef __cplusplus
struct edgwll__QueryConditions *soapConds, *soapConds2;
edg_wll_QueryRec **stdConds2;
int ret;
+ int size;
+ void *tmp1;
ret = edg_wll_QueryCondsExtToSoap(soap, (const edg_wll_QueryRec**)stdConds, &soapConds);
CPPUNIT_ASSERT_MESSAGE("edg_wll_QueryCondsExtToSoap()", ret == SOAP_OK);
- ret = edg_wll_SoapToQueryCondsExt(soapConds, &stdConds2);
+ ret = edg_wll_SoapToQueryCondsExt(soapConds, &stdConds2, &size, &tmp);
CPPUNIT_ASSERT_MESSAGE("edg_wll_SoapToQueryCondsExt()", !ret);
CPPUNIT_ASSERT_MESSAGE("Converted std results differs", !stdCondsCmp(stdConds, stdConds2));