dropping attributes tables just before creating (nifty when deleted attrs table)
fixed ugly bug in updateJobs (forgotten fetch)
#ident "$Header$"
+#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
void glite_jp_lprintf(const char *source, const char *fmt, ...) {
va_list ap;
- printf("%s: ", source);
+ printf("[%d] %s: ", getpid(), source);
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
// insert
if (glite_jp_db_execute(stmt) == -1) goto fail;
+ // silently drop
+ sql[sizeof(sql) - 1] = '\0';
+ snprintf(sql, sizeof(sql), SQLCMD_DROP_DATA_TABLE, attrid);
+ llprintf(LOG_SQL, "preventive dropping '%s' ==> '%s'\n", attrid, sql);
+ glite_jp_db_execstmt(jpctx, sql, NULL);
+
+ // create table
sql[sizeof(sql) - 1] = '\0';
snprintf(sql, sizeof(sql) - 1, SQLCMD_CREATE_DATA_TABLE, attrid, type_index, type_full);
llprintf(LOG_SQL, "creating table: '%s'\n", sql);
glite_jp_db_create_results(&myres, 2,
GLITE_JP_DB_TYPE_INT, NULL, &(isctx->param_uniqueid),
GLITE_JP_DB_TYPE_VARCHAR, NULL, isctx->param_ps, sizeof(isctx->param_ps), &isctx->param_ps_len);
- if ((ret = glite_jp_db_prepare(jpctx, "SELECT uniqueid, source FROM feeds WHERE (locked=0) AND (feedid IS NULL) AND ((state <> " GLITE_JP_IS_STATE_ERROR_STR ") OR (expires <= ?))", &isctx->select_unlocked_feed_stmt, myparam, myres)) != 0) goto fail;
+ if ((ret = glite_jp_db_prepare(jpctx, "SELECT uniqueid, source FROM feeds WHERE (locked=0) AND (feedid IS NULL) AND ((state < " GLITE_JP_IS_STATE_ERROR_STR ") OR (expires <= ?))", &isctx->select_unlocked_feed_stmt, myparam, myres)) != 0) goto fail;
// sql command: lock the feed (via uniqueid)
glite_jp_db_create_params(&myparam, 1, GLITE_JP_DB_TYPE_INT, &isctx->param_uniqueid);
/* Helper functions */
/*------------------*/
-#define dprintf(FMT, ARGS, ...)
#include "glite/jp/ws_fault.c"
-#define err2fault(CTX, SOAP) glite_jp_server_err2fault((CTX), (SOAP))
// get info about the feed
feedid = jpelem__UpdateJobs->feedId;
+ lprintf("feedid='%s'\n", feedid);
+
GLITE_JPIS_PARAM(ctx->param_feedid, ctx->param_feedid_len, feedid);
if ((ret = glite_jp_db_execute(ctx->select_info_feed_stmt)) != 1) {
fprintf(stderr, "can't get info about feed '%s', returned %d records", feedid, ret);
else fprintf(stderr, "\n");
goto fail;
}
+ if (glite_jp_db_fetch(ctx->select_info_feed_stmt) != 0) {
+ fprintf(stderr, "can't fetch feed '%s'", feedid);
+ if (jpctx->error) fprintf(stderr, ": %s (%s)\n", jpctx->error->desc, jpctx->error->source);
+ else fprintf(stderr, "\n");
+ goto fail;
+ }
+ lprintf("uniqueid=%ld, state=%d, source='%s'\n", ctx->param_uniqueid, ctx->param_state, ctx->param_ps);
ps = strdup(ctx->param_ps);
+
// update status, if needed (only orig)
status = ctx->param_state;
done = jpelem__UpdateJobs->feedDone ? GLITE_JP_IS_STATE_DONE : 0;
struct jptype__jobRecord *jr;
char **jobids = NULL, **ps_list = NULL;
- int i, size;
+ int i, size, err;
puts(__FUNCTION__);
}
/* get all jobids matching the conditions */
- if ( get_jobids(ctx, in, &jobids, &ps_list) ) {
- glite_jpis_stack_error(ctx->jpctx, 0, NULL);
+ if ( (err = get_jobids(ctx, in, &jobids, &ps_list)) != 0 ) {
+ glite_jpis_stack_error(ctx->jpctx, err, "Error getting jobs");
goto fail;
}
GLITE_SECURITY_GSOAP_LIST_CREATE(soap, out, jobs, struct jptype__jobRecord, size);
for (i=0; (jobids && jobids[i]); i++) {
jr = GLITE_SECURITY_GSOAP_LIST_GET(out->jobs, i);
- if ( get_attrs(soap, ctx, jobids[i], in, jr) ) {
- glite_jpis_stack_error(ctx->jpctx, 0, NULL);
+ if ( (err = get_attrs(soap, ctx, jobids[i], in, jr)) != 0 ) {
+ glite_jpis_stack_error(ctx->jpctx, err, "Error getting attributes of the job '%s'", jobids[i]);
goto fail;
}
extern struct Namespace jp__namespaces[];
-int debug = 0;
/*------------------*/
/* Helper functions */
/*------------------*/
-#define dprintf(FMT, ARGS...) if (debug) fprintf(stderr, FMT, ##ARGS)
+#define dprintf(FMT, ARGS...) do {fprintf(stderr, "[%d] %s: ", getpid(), __FUNCTION__); fprintf(stderr, FMT, ##ARGS); } while(0);
#include "glite/jp/ws_fault.c"
#define check_fault(SOAP, ERR) glite_jp_clientCheckFault((SOAP), (ERR), NULL, 0)
char *src, *desc = NULL;
lprintf("(%ld) for %s called\n", uniqueid, dest);
- debug = conf->debug;
glite_gsplugin_init_context(&plugin_ctx);
if (ctx->conf->server_key) plugin_ctx->key_filename = strdup(ctx->conf->server_key);
in.history = conf->feeds[dest_index]->history;
in.continuous = conf->feeds[dest_index]->continuous;
in.destination = ctx->hname;
- lprintf("(%ld) destination IS: %s\n", uniqueid, ctx->hname);
+ lprintf("(%ld) destination IS: '%s'\n", uniqueid, ctx->hname);
if (check_fault(soap,soap_call___jpsrv__FeedIndex(soap,dest,"", &in, &out)) != 0) {
fprintf(stderr, "\n");