Fix default parameter settings.
Check return codes of egd_wll_InitContext() calls.
"[-s source_id] -e event [key=value ...]");
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context\n");
+ exit(1);
+ }
/* log the event - priority/normal/proxy */
logev = (pri) ? edg_wll_LogEventSync : edg_wll_LogEvent;
// sleep(20);
me = argv[0];
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
if ( argc < 2 ) {
usage(NULL); goto cleanup;
default: usage(argv[0]); exit(1);
}
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
if (!jobid_s || type == EDG_WLL_SANDBOX_SANDBOX_TYPE_UNDEFINED
|| !from || !to)
int edg_wll_InitContext(edg_wll_Context *ctx)
{
- int i;
+ int i, ret;
edg_wll_Context out = (edg_wll_Context) malloc(sizeof(*out));
+ union {
+ int i;
+ char *s;
+ struct timeval *tv;
+ } null;
if (!out) return ENOMEM;
memset(out,0,sizeof(*out));
out->allowAnonymous = 1;
out->notifSock = -1;
- /* XXX */
- for (i=0; i<EDG_WLL_PARAM__LAST; i++) edg_wll_SetParam(out,i,NULL);
+ memset(&null, 0, sizeof null);
+ for (i=0; i<EDG_WLL_PARAM__LAST; i++) {
+ if ((ret = edg_wll_SetParam(out,i,null)) != 0) {
+ edg_wll_FreeParams(out);
+ free(out);
+ return ret;
+ }
+ }
out->p_tmp_timeout.tv_sec = out->p_log_timeout.tv_sec;
out->p_tmp_timeout.tv_usec = out->p_log_timeout.tv_usec;
- out->connections = edg_wll_initConnections();
out->connNotif = (edg_wll_Connections *) calloc(1, sizeof(edg_wll_Connections));
- edg_wll_initConnNotif(out->connNotif);
out->connProxy = (edg_wll_ConnProxy *) calloc(1, sizeof(edg_wll_ConnProxy));
+ if (!out->connNotif || !out->connProxy) goto enomem;
+ out->connections = edg_wll_initConnections();
+ edg_wll_initConnNotif(out->connNotif);
out->connProxy->conn.sock = -1;
// out->connToUse = -1;
#endif
return 0;
+enomem:
+ edg_wll_FreeParams(out);
+ free(out->connNotif);
+ free(out->connProxy);
+ free(out);
+ return ENOMEM;
}
void edg_wll_FreeContext(edg_wll_Context ctx)
{
edg_wll_Context ctx;
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "edg_wll_InitContext() failed\n");
+ return(-1);
+ }
if(trio_asprintf(&termination_string, EDG_WLL_FORMAT_USERTAG,
PERFTEST_END_TAG_NAME, PERFTEST_END_TAG_VALUE) < 0)
ctx->p_query_results = val;
}
else {
- char *s = extract_split(param,'/',0);
- if (s) {
- val = edg_wll_StringToQResult(s);
- if (!val) return edg_wll_SetError(ctx,EINVAL,"can't parse query result parameter name");
- ctx->p_query_results = val;
- free(s);
- }
- return edg_wll_SetError(ctx,EINVAL,"can't parse query result parameter name");
+ if (mygetenv(param)) {
+ char *s = extract_split(param,'/',0);
+ if (s) {
+ val = edg_wll_StringToQResult(s);
+ if (!val) return edg_wll_SetError(ctx,EINVAL,"can't parse query result parameter name");
+ ctx->p_query_results = val;
+ free(s);
+ } else
+ return edg_wll_SetError(ctx,EINVAL,"can't parse query result parameter name");
+ } // else default EDG_WLL_QUERYRES_UNDEF
}
break;
case EDG_WLL_PARAM_CONNPOOL_SIZE:
ctx->p_source = val;
}
else {
- char *s = extract_split(param,'/',0);
- if (s) {
- val = edg_wll_StringToSource(s);
- if (!val) return edg_wll_SetError(ctx,EINVAL,"can't parse source name");
- ctx->p_source = val;
- free(s);
- }
- return edg_wll_SetError(ctx,EINVAL,"can't parse source name");
+ if (mygetenv(param)) {
+ char *s = extract_split(param,'/',0);
+ if (s) {
+ val = edg_wll_StringToSource(s);
+ if (!val) return edg_wll_SetError(ctx,EINVAL,"can't parse source name");
+ ctx->p_source = val;
+ free(s);
+ } else
+ return edg_wll_SetError(ctx,EINVAL,"can't parse source name");
+ } // else default EDG_WLL_SOURCE_NONE
}
break;
default:
edg_wll_Event *e1,*e2;
char *line,*et,*ed;
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ std::cerr << std::string("edg_wll_InitContext() failed") << std::endl;
+ exit(1);
+ }
e1 = edg_wll_InitEvent(EDG_WLL_EVENT_$u);
gettimeofday(&e1->any.timestamp,NULL);
}
}
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ lprintf(NULL, ERR, "can't init LB context");
+ goto quit;
+ }
if (config.cert) edg_wll_SetParam(ctx, EDG_WLL_PARAM_X509_CERT, config.cert);
if (config.key) edg_wll_SetParam(ctx, EDG_WLL_PARAM_X509_KEY, config.key);
last_summary = 0;
else fname = argv[optind];
}
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.");
+ exit(1);
+ }
if (!dbstring) dbstring = DEFAULTCS;
if (edg_wll_Open(ctx,dbstring)) do_exit(ctx,EX_UNAVAILABLE);
if ((ctx->dbcaps = glite_lbu_DBQueryCaps(ctx->dbctx)) == -1) do_exit(ctx, EX_SOFTWARE);
purge_timeout[EDG_WLL_JOB_CLEARED] = 60*60*24*3;
purge_timeout[EDG_WLL_JOB_ABORTED] = 60*60*24*7;
purge_timeout[EDG_WLL_JOB_CANCELLED] = 60*60*24*7;
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context, exiting.\n");
+ exit(1);
+ }
while ((opt = getopt_long(argc,argv,get_opt_string,opts,NULL)) != EOF) switch (opt) {
case 'A': enable_lcas = 1; break;
lcas_log_debug(1,"\t%s-plugin: checking LB access policy\n",
modname);
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ lcas_log(0, "Couldn't create L&B context\n");
+ ret = LCAS_MOD_FAIL;
+ goto end;
+ }
if ((action = find_authz_action(request)) == ACTION_UNDEF) {
lcas_log(0, "lcas.mod-lb() error: unsupported action\n");
case '?': usage(); exit(EX_USAGE);
}
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
for (i = 1; i<EDG_WLL_NUMBER_OF_STATCODES; i++) jobs[i] = 0;
if (edg_wll_Open(ctx,dbstring)) do_exit(ctx,EX_UNAVAILABLE);
if ((caps = glite_lbu_DBQueryCaps(ctx->dbctx)) < 0 || !(caps & GLITE_LBU_DB_CAP_INDEX)) do_exit(ctx,EX_SOFTWARE);
}
/* initialize context */
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
if ( server )
{
char *p = strrchr(server, ':');
ret = 0;
memset(&buf, 0, sizeof(buf));
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
while ( 1 ) {
int rl_ret,
written,
}
/* initialize context */
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
if ( server )
{
char *p = strrchr(server, ':');
if (me) me++; else me=argv[0];
/* initialize context */
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
/* get arguments */
while ((opt = getopt_long(argc,argv,"a:c:n:e:o:j:m:rlsidhvxX:t:b:",opts,NULL)) != EOF) {
}
- edg_wll_InitContext(&ctx);
+ if (edg_wll_InitContext(&ctx) != 0) {
+ fprintf(stderr, "Couldn't create L&B context.\n");
+ exit(1);
+ }
jc[0].attr = EDG_WLL_QUERY_ATTR_JOBID;
jc[0].op = EDG_WLL_QUERY_OP_EQUAL;