#include <netdb.h>
#include <limits.h>
#include <assert.h>
-#include <syslog.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include "glite/lb/context.h"
#include "glite/lb/mini_http.h"
#include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
#ifdef LB_PERF
#include "glite/lb/lb_perftest.h"
setlinebuf(stdout);
setlinebuf(stderr);
- dprintf(("\n"));
- if (mode & SERVICE_PROXY) dprintf(("Starting LB proxy service\n"));
- if (mode & SERVICE_SERVER) dprintf(("Starting LB server service\n"));
- dprintf(("\n"));
+ if (glite_common_log_init()) {
+ fprintf(stderr,"glite_common_log_init() failed, exiting.\n");
+ exit(1);
+ }
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Initializing...");
+
+ if (mode & SERVICE_PROXY) glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Starting LB proxy service");
+ if (mode & SERVICE_SERVER) glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Starting LB server service");
// XXX: workaround for only preudoparallel job registration
// we need at least 2 slaves to avoid locking misbehaviour
if ((mode == SERVICE_PROXY_SERVER) && (slaves == 1)) {
- dprintf(("WARNING: Running both proxy and server services enforces at least 2 slaves\n"));
- dprintf(("Starting 2 slaves\n"));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "Running both proxy and server services enforces at least 2 slaves");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "Starting 2 slaves");
slaves = 2;
}
{
if ( !kill(opid,0) )
{
- fprintf(stderr,"%s: another instance running, pid = %d\n",argv[0],opid);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "%s: another instance running, pid = %d", argv[0], opid);
return 1;
}
else if (errno != ESRCH) { perror("kill()"); return 1; }
if (fclose(fpid) != 0) { perror(pidfile); return 1; }
if (mode & SERVICE_SERVER) {
- if (check_mkdir(dumpStorage)) exit(1);
- if (check_mkdir(purgeStorage)) exit(1);
+ if (check_mkdir(dumpStorage)){
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Directory for dump files not redy!");
+ exit(1);
+ }
+ if (check_mkdir(purgeStorage)){
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Directory for purge files not redy!");
+ exit(1);
+ }
if ( jpreg ) {
if ( glite_lbu_MaildirInit(jpregDir) ) {
- dprintf(("[%d] glite_lbu_MaildirInit failed: %s\n", getpid(), lbm_errdesc));
- if (!debug) syslog(LOG_CRIT, "glite_lbu_MaildirInit failed: %s", lbm_errdesc);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "[%d] glite_lbu_MaildirInit failed: %s", getpid(), lbm_errdesc);
exit(1);
}
}
fake_port = atoi(port);
}
- dprintf(("Server address: %s:%d\n", fake_host, fake_port));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Server address: %s:%d", fake_host, fake_port);
}
if ((mode & SERVICE_SERVER)) {
service_table[SRV_SERVE].conn = socket(PF_INET, SOCK_STREAM, 0);
- if ( service_table[SRV_SERVE].conn < 0 ) { perror("socket()"); return 1; }
+ if ( service_table[SRV_SERVE].conn < 0 ) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+ return 1;
+ }
a.sin_family = AF_INET;
a.sin_port = htons(atoi(port));
a.sin_addr.s_addr = INADDR_ANY;
setsockopt(service_table[SRV_SERVE].conn, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
if ( bind(service_table[SRV_SERVE].conn, (struct sockaddr *) &a, sizeof(a)) )
{
- char buf[100];
-
- snprintf(buf,sizeof(buf),"bind(%d)",atoi(port));
- perror(buf);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%d)",atoi(port));
return 1;
}
- if ( listen(service_table[SRV_SERVE].conn, CON_QUEUE) ) { perror("listen()"); return 1; }
+ if ( listen(service_table[SRV_SERVE].conn, CON_QUEUE) ) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()");
+ return 1;
+ }
service_table[SRV_STORE].conn = socket(PF_INET, SOCK_STREAM, 0);
- if ( service_table[SRV_STORE].conn < 0) { perror("socket()"); return 1; }
+ if ( service_table[SRV_STORE].conn < 0) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+ return 1;
+ }
a.sin_family = AF_INET;
a.sin_port = htons(atoi(port)+1);
a.sin_addr.s_addr = INADDR_ANY;
setsockopt(service_table[SRV_STORE].conn, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
if ( bind(service_table[SRV_STORE].conn, (struct sockaddr *) &a, sizeof(a)))
{
- char buf[100];
-
- snprintf(buf,sizeof(buf), "bind(%d)", atoi(port)+1);
- perror(buf);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%d)", atoi(port)+1);
return 1;
}
- if ( listen(service_table[SRV_STORE].conn, CON_QUEUE) ) { perror("listen()"); return 1; }
+ if ( listen(service_table[SRV_STORE].conn, CON_QUEUE) ) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()");
+ return 1;
+ }
#ifdef GLITE_LB_SERVER_WITH_WS
service_table[SRV_WS].conn = socket(PF_INET, SOCK_STREAM, 0);
- if ( service_table[SRV_WS].conn < 0) { perror("socket()"); return 1; }
+ if ( service_table[SRV_WS].conn < 0) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+ return 1;
+ }
a.sin_family = AF_INET;
a.sin_port = htons(atoi(ws_port));
a.sin_addr.s_addr = INADDR_ANY;
setsockopt(service_table[SRV_WS].conn, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
if ( bind(service_table[SRV_WS].conn, (struct sockaddr *) &a, sizeof(a)))
{
- char buf[100];
-
- snprintf(buf, sizeof(buf), "bind(%d)", atoi(ws_port));
- perror(buf);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%d)", atoi(ws_port));
return 1;
}
if ( listen(service_table[SRV_WS].conn, CON_QUEUE) ) { perror("listen()"); return 1; }
#endif /* GLITE_LB_SERVER_WITH_WS */
if (!server_cert || !server_key)
- fprintf(stderr, "%s: key or certificate file not specified"
- " - unable to watch them for changes!\n", argv[0]);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "%s: key or certificate file not specified - unable to watch them for changes!", argv[0]);
if ( cadir ) setenv("X509_CERT_DIR", cadir, 1);
edg_wll_gss_watch_creds(server_cert, &cert_mtime);
{
int i;
- dprintf(("Server identity: %s\n",mycred->name));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Server identity: %s", mycred->name);
server_subject = strdup(mycred->name);
for ( i = 0; super_users && super_users[i]; i++ ) ;
super_users = realloc(super_users, (i+2)*sizeof(*super_users));
super_users[i+1] = NULL;
}
else {
- dprintf(("Server running unauthenticated\n"));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "Server running unauthenticated");
server_subject = strdup("anonymous LB");
}
- if ( noAuth ) dprintf(("Server in promiscuous mode\n"));
- dprintf(("Server listening at %d,%d (accepting protocols: " COMP_PROTO " and compatible) ...\n",atoi(port),atoi(port)+1));
+ if ( noAuth )
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Server in promiscuous mode");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ "Server listening at %d,%d (accepting protocols: " COMP_PROTO " and compatible) ...", atoi(port), atoi(port)+1);
#ifdef GLITE_LB_SERVER_WITH_WS
- dprintf(("Server listening at %d (accepting web service protocol) ...\n", atoi(ws_port)));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ "Server listening at %d (accepting web service protocol) ...", atoi(ws_port));
#endif /* GLITE_LB_SERVER_WITH_WS */
}
struct sockaddr_un a;
service_table[SRV_SERVE_PROXY].conn = socket(PF_UNIX, SOCK_STREAM, 0);
- if ( service_table[SRV_SERVE_PROXY].conn < 0 ) { perror("socket()"); return 1; }
+ if ( service_table[SRV_SERVE_PROXY].conn < 0 ) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+ return 1;
+ }
memset(&a, 0, sizeof(a));
a.sun_family = AF_UNIX;
sprintf(sock_serve, "%s%s", socket_path_prefix, "serve.sock");
if( connect(service_table[SRV_SERVE_PROXY].conn, (struct sockaddr *)&a, sizeof(a.sun_path)) < 0) {
if( errno == ECONNREFUSED ) {
- dprintf(("removing stale input socket %s\n", sock_serve));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "removing stale input socket %s", sock_serve);
unlink(sock_serve);
}
- } else { perror("another instance of lb-proxy is running"); return 1; }
+ } else {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "another instance of lb-proxy is running");
+ return 1;
+ }
if ( bind(service_table[SRV_SERVE_PROXY].conn, (struct sockaddr *) &a, sizeof(a)) < 0 ) {
- char buf[100];
-
- snprintf(buf, sizeof(buf), "bind(%s)", sock_serve);
- perror(buf);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%s)", sock_serve);
return 1;
}
- if ( listen(service_table[SRV_SERVE_PROXY].conn, con_queue) ) { perror("listen()"); return 1; }
+ if ( listen(service_table[SRV_SERVE_PROXY].conn, con_queue) ) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()");
+ return 1;
+ }
service_table[SRV_STORE_PROXY].conn = socket(PF_UNIX, SOCK_STREAM, 0);
- if ( service_table[SRV_STORE_PROXY].conn < 0 ) { perror("socket()"); return 1; }
+ if ( service_table[SRV_STORE_PROXY].conn < 0 ) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+ return 1;
+ }
memset(&a, 0, sizeof(a));
a.sun_family = AF_UNIX;
sprintf(sock_store, "%s%s", socket_path_prefix, "store.sock");
if( connect(service_table[SRV_STORE_PROXY].conn, (struct sockaddr *)&a, sizeof(a.sun_path)) < 0) {
if( errno == ECONNREFUSED ) {
- dprintf(("removing stale input socket %s\n", sock_store));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "removing stale input socket %s", sock_store);
unlink(sock_store);
}
- } else { perror("another instance of lb-proxy is running"); return 1; }
+ } else {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "another instance of lb-proxy is running");
+ return 1;
+ }
if ( bind(service_table[SRV_STORE_PROXY].conn, (struct sockaddr *) &a, sizeof(a))) {
- char buf[100];
-
- snprintf(buf, sizeof(buf), "bind(%s)", sock_store);
- perror(buf);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%s)", sock_store);
+
return 1;
}
- if ( listen(service_table[SRV_STORE_PROXY].conn, con_queue) ) { perror("listen()"); return 1; }
+ if ( listen(service_table[SRV_STORE_PROXY].conn, con_queue) ) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()");
+ return 1;
+ }
- dprintf(("Proxy listening at %s, %s ...\n", sock_store, sock_serve));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Proxy listening at %s, %s ...", sock_store, sock_serve);
}
if (!dbstring) dbstring = getenv("LBDB");
char *et,*ed;
glite_lbu_DBError(ctx->dbctx,&et,&ed);
- fprintf(stderr,"%s: open database: %s (%s)\n",argv[0],et,ed);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "%s: open database: %s (%s)", argv[0], et, ed);
free(et); free(ed);
return 1;
}
edg_wll_Close(ctx);
ctx->dbctx = NULL;
- fprintf(stderr, "[%d]: DB '%s'\n", getpid(), dbstring);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d]: DB '%s'", getpid(), dbstring);
if ((ctx->dbcaps & GLITE_LBU_DB_CAP_INDEX) == 0) {
- fprintf(stderr,"%s: missing index support in DB layer\n",argv[0]);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "%s: missing index support in DB layer", argv[0]);
return 1;
}
if ((ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS) == 0)
- fprintf(stderr, "[%d]: transactions aren't supported!\n", getpid());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d]: transactions aren't supported!", getpid());
if (transactions >= 0) {
- fprintf(stderr, "[%d]: transactions forced from %d to %d\n", getpid(), ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS ? 1 : 0, transactions);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d]: transactions forced from %d to %d", getpid(), ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS ? 1 : 0, transactions);
ctx->dbcaps &= ~GLITE_LBU_DB_CAP_TRANSACTIONS;
ctx->dbcaps |= transactions ? GLITE_LBU_DB_CAP_TRANSACTIONS : 0;
}
if ( !debug ) {
if (daemon(1,0) == -1) {
- perror("deamon()");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "deamon()");
exit(1);
}
#ifdef LB_PERF
if (!fpid) { perror(pidfile); return 1; }
fprintf(fpid,"%d",getpid());
fclose(fpid);
-
- openlog(name,LOG_PID,LOG_DAEMON);
} else {
setpgid(0, getpid());
}
return -1;
}
- dprintf(("[%d] opening database ...\n", getpid()));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d] opening database ...", getpid());
wait_for_open(ctx, dbstring);
glite_lbu_DBSetCaps(ctx->dbctx, use_dbcaps);
cdata->dbctx = ctx->dbctx;
char *et, *ed;
edg_wll_Error(ctx,&et,&ed);
- dprintf(("[%d]: query_job_indices(): %s: %s, no custom indices available\n",getpid(),et,ed));
- if (!debug) syslog(LOG_ERR,"[%d]: query_job_indices(): %s: %s, no custom indices available\n",getpid(),et,ed);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d]: query_job_indices(): %s: %s, no custom indices available", getpid(), et, ed);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_DEBUG, "[%d]: query_job_indices(): %s: %s, no custom indices available", getpid(), et, ed);
free(et);
free(ed);
}
char *et,*ed;
edg_wll_Error(ctx,&et,&ed);
- dprintf(("[%d]: query notif indices: %s: %s\n",getpid(),et,ed));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d]: query notif indices: %s: %s", getpid(), et, ed);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_DEBUG, "[%d]: query notif indices: %s: %s", getpid(), et, ed);
+
free(et); free(ed);
}
cdata->notif_index = notif_index;
case 0: break;
case 1:
if ( !edg_wll_gss_acquire_cred_gsi(server_cert, server_key, &newcred, &gss_code) ) {
- dprintf(("[%d] reloading credentials successful\n", getpid()));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] reloading credentials successful", getpid());
edg_wll_gss_release_cred(&mycred, NULL);
mycred = newcred;
- } else { dprintf(("[%d] reloading credentials failed, using old ones\n", getpid())); }
+ } else {
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_ERROR, "[%d] reloading credentials failed, using old ones");
+ }
+ break;
+ case -1:
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_ERROR, "[%d] edg_wll_gss_watch_creds failed", getpid());
break;
- case -1: dprintf(("[%d] edg_wll_gss_watch_creds failed\n", getpid())); break;
}
if ( edg_wll_InitContext(&ctx) )
{
- fprintf(stderr, "Couldn't create context");
+ //fprintf(stderr, "Couldn't create context");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Couldn't create context");
return -1;
}
cdata->ctx = ctx;
switch ( h_errno )
{
case NETDB_SUCCESS:
- if (name) dprintf(("[%d] connection from %s:%d (%s)\n",
- getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port), name));
+ if (name)
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_INFO, "[%d] connection from %s:%d (%s)", getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port), name);
free(ctx->connections->serverConnection->peerName);
ctx->connections->serverConnection->peerName = name;
name = NULL;
break;
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)));
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_DEBUG, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_INFO,"[%d] connection from %s:%d", 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;
gettimeofday(&now, 0);
if ( decrement_timeout(timeout, conn_start, now) )
{
- if (debug) fprintf(stderr, "gethostbyaddr() timeout");
- else syslog(LOG_ERR, "gethostbyaddr(): timeout");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR, "gethostbyaddr() timeout");
free(name);
return -1;
{
if ( strcmp(name, server_name))
{
- if (debug) fprintf(stderr, "different server endpoint names (%s,%s),"
- " check DNS PTR records\n", name, server_name);
- else syslog(LOG_ERR,"different server endpoint names (%s,%s),"
- " check DNS PTR records\n", name, server_name);
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR, "different server endpoint names (%s,%s), check DNS PTR records", name, server_name);
}
}
else server_name = strdup(name);
break;
default:
- if ( debug )
- fprintf(stderr, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
- else
- syslog(LOG_ERR,"gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_ERROR, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
if ( server_name != NULL )
ctx->srvName = strdup(server_name);
break;
{
if ( ret == EDG_WLL_GSS_ERROR_TIMEOUT )
{
- 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);
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_WARN, "[%d] %s: Client authentication failed - timeout reached, closing.", getpid(),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);
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_WARN, "[%d] %s: false expired certificate: %s",getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc);
edg_wll_FreeContext(ctx);
return -1;
}
- dprintf(("[%d] %s: GSS error: %s, closing.\n", getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc));
- if (!debug) syslog(LOG_ERR, "%s: GSS error: %s",ctx->connections->serverConnection->peerName,ctx->errDesc);
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_ERROR, "[%d] %s: GSS error: %s", getpid(), ctx->connections->serverConnection->peerName, ctx->errDesc);
}
else
{
- 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);
-
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_WARN, "[%d] %s: Client authentication failed", getpid(), ctx->connections->serverConnection->peerName);
}
edg_wll_FreeContext(ctx);
return 1;
ret = edg_wll_gss_get_client_conn(&ctx->connections->serverConnection->gss, &client, NULL);
if (ret || client->flags & EDG_WLL_GSS_FLAG_ANON) {
- dprintf(("[%d] anonymous client\n",getpid()));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] anonymous client",getpid());
ctx->peerName = NULL;
} else {
if (ctx->peerName) free(ctx->peerName);
ctx->peerName = strdup(client->name);
edg_wll_gss_free_princ(client);
-
- dprintf(("[%d] client DN: %s\n",getpid(),ctx->peerName));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] client DN: %s",getpid(),ctx->peerName);
}
if ( edg_wll_SetVomsGroups(ctx, &ctx->connections->serverConnection->gss, server_cert, server_key, vomsdir, cadir) )
char *errt, *errd;
edg_wll_Error(ctx, &errt, &errd);
- dprintf(("[%d] %s (%s)\n[%d]\tignored, continuing without VOMS\n", getpid(), errt, errd,getpid()));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] %s (%s)\n[%d]\tignored, continuing without VOMS", getpid(), errt, errd,getpid());
free(errt); free(errd);
edg_wll_ResetError(ctx);
}
- if (debug && ctx->vomsGroups.len > 0)
+ if (ctx->vomsGroups.len > 0)
{
int i;
- dprintf(("[%d] client's VOMS groups:\n",getpid()));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "[%d] client's VOMS groups:",getpid());
for ( i = 0; i < ctx->vomsGroups.len; i++ )
- dprintf(("\t%s:%s\n", ctx->vomsGroups.val[i].vo, ctx->vomsGroups.val[i].name));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "\t%s:%s", ctx->vomsGroups.val[i].vo, ctx->vomsGroups.val[i].name);
}
- if (debug && ctx->fqans && *(ctx->fqans))
+ if (ctx->fqans && *(ctx->fqans))
{
char **f;
- dprintf(("[%d] client's FQANs:\n",getpid()));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "[%d] client's FQANs:",getpid());
for (f = ctx->fqans; f && *f; f++)
- dprintf(("\t%s\n", *f));
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "\t%s", *f);
}
/* used also to reset start_time after edg_wll_ssl_accept! */
int err = 0;
if ( glite_gsplugin_init_context(&gsplugin_ctx) ) {
- fprintf(stderr, "Couldn't create gSOAP plugin context");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+ "Couldn't create gSOAP plugin context");
return -1;
}
if ( !(soap = soap_new()) ) {
- fprintf(stderr, "Couldn't create soap environment");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+ "Couldn't create soap environment");
goto err;
}
soap_init2(soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);
if ( soap_set_namespaces(soap, namespaces) ) {
soap_done(soap);
- perror("Couldn't set soap namespaces");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+ "Couldn't set soap namespaces");
goto err;
}
if ( soap_register_plugin_arg(soap, glite_gsplugin, gsplugin_ctx) ) {
soap_done(soap);
- perror("Couldn't set soap namespaces");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+ "Couldn't set soap namespaces");
goto err;
}
struct timeval conn_start, now;
if ( edg_wll_InitContext(&ctx) ) {
- dprintf(("Couldn't create context"));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "Couldn't create context");
return -1;
}
cdata->ctx = ctx;
ctx->connProxy = (edg_wll_ConnProxy *) calloc(1, sizeof(edg_wll_ConnProxy));
if ( !ctx->connProxy ) {
- perror("calloc");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "calloc");
edg_wll_FreeContext(ctx);
return -1;
gettimeofday(&conn_start, 0);
if ( edg_wll_plain_accept(conn, &ctx->connProxy->conn) ) {
- perror("accept");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+ "accept");
edg_wll_FreeContext(ctx);
return -1;
gettimeofday(&now, 0);
if ( decrement_timeout(timeout, conn_start, now) ) {
- if (debug) fprintf(stderr, "edg_wll_plain_accept() timeout");
- else syslog(LOG_ERR, "edg_wll_plain_accept(): timeout");
-
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_WARN,
+ "edg_wll_plain_accept(): timeout");
return -1;
}
case EPIPE:
case EIO:
case EDG_WLL_IL_PROTO:
- dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
- if (!debug) syslog(LOG_ERR,"%s (%s)", errt, errd);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "[%d] %s (%s)", getpid(), errt, errd);
/* fallthrough
*/
case ENOTCONN:
case EEXIST:
case EDG_WLL_ERROR_NOINDEX:
case E2BIG:
- dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "[%d] %s (%s)", getpid(), errt, errd);
break;
case EINVAL:
case EDG_WLL_ERROR_PARSE_BROKEN_ULM:
case EDG_WLL_ERROR_PARSE_OK_WITH_EXTRA_FIELDS:
case EDG_WLL_ERROR_JOBID_FORMAT:
case EDG_WLL_ERROR_MD5_CLASH:
- dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
- if ( !debug ) syslog(LOG_ERR,"%s (%s)", errt, errd);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "[%d] %s (%s)", getpid(), errt, errd);
/*
* no action for non-fatal errors
*/
case EDG_WLL_ERROR_DB_CALL:
case EDG_WLL_ERROR_SERVER_RESPONSE:
default:
- dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
- if (!debug) syslog(LOG_CRIT,"%s (%s)",errt,errd);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL,
+ "[%d] %s (%s)", getpid(), errt, errd);
/*
* unknown error - do rather return (<0) (slave will be killed)
*/
gettimeofday(&after, NULL);
if ( decrement_timeout(timeout, before, after) ) {
- if (debug) fprintf(stderr, "Serving store connection timed out");
- else syslog(LOG_ERR, "Serving store connection timed out");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_WARN,
+ "Serving store connection timed out");
return ETIMEDOUT;
}
gettimeofday(&after, NULL);
if ( decrement_timeout(timeout, before, after) ) {
- if (debug) fprintf(stderr, "Serving store connection timed out");
- else syslog(LOG_ERR, "Serving store connection timed out");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_WARN,
+ "Serving store connection timed out");
+
return ETIMEDOUT;
}
if ( err ) {
// soap_print_fault(struct soap *soap, FILE *fd) maybe useful here
- dprintf(("[%d] SOAP error (bk_accept_ws) \n", getpid()));
- if (!debug) syslog(LOG_CRIT,"SOAP error (bk_accept_ws)");
+ glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+ "[%d] SOAP error (bk_accept_ws)", getpid());
return ECANCELED;
}
while (((err = edg_wll_Open(ctx, (char *) dbstring)) != EDG_WLL_ERROR_DB_INIT) && err) {
if (dbfail_string1) free(dbfail_string1);
edg_wll_Error(ctx,&errt,&errd);
- asprintf(&dbfail_string1,"%s (%s)\n",errt,errd);
+ asprintf(&dbfail_string1,"%s (%s)",errt,errd);
if (dbfail_string1 != NULL) {
if (dbfail_string2 == NULL || strcmp(dbfail_string1,dbfail_string2)) {
if (dbfail_string2) free(dbfail_string2);
dbfail_string2 = dbfail_string1;
dbfail_string1 = NULL;
- dprintf(("[%d]: %s\nStill trying ...\n",getpid(),dbfail_string2));
- if (!debug) syslog(LOG_ERR,dbfail_string2);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d]: %s\nStill trying ...",getpid(),dbfail_string2);
+
}
}
sleep(5);
if (dbfail_string1) free(dbfail_string1);
if (dbfail_string2 != NULL) {
free(dbfail_string2);
- dprintf(("[%d]: DB connection established\n",getpid()));
- if (!debug) syslog(LOG_INFO,"DB connection established\n");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ "[%d]: DB connection established",getpid());
}
if (err) {
edg_wll_Error(ctx,&errt,&errd);
- asprintf(&dbfail_string1,"%s (%s)\n",errt,errd);
- dprintf(("[%d]: %s\n", getpid(), dbfail_string1));
- if (!debug) syslog(LOG_ERR,dbfail_string1);
+ asprintf(&dbfail_string1,"%s (%s)",errt,errd);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "[%d]: %s", getpid(), dbfail_string1);
free(dbfail_string1);
}
char buf[BUFSIZ];
if (!roots) {
- syslog(LOG_WARNING,"%s: %m, continuing without --super-users-file",file);
- dprintf(("%s: %s, continuing without --super-users-file\n",file,strerror(errno)));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "%s: %s, continuing without --super-users-file",file,strerror(errno));
return 0;
}
{
if ( mkdir(dir, S_IRWXU) )
{
- dprintf(("[%d] %s: %s\n", getpid(), dir, strerror(errno)));
- if (!debug) syslog(LOG_CRIT, "%s: %m", dir);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d] %s: %s", getpid(), dir, strerror(errno));
return 1;
}
}
else
{
- dprintf(("[%d] %s: %s\n", getpid(), dir, strerror(errno)));
- if (!debug) syslog(LOG_CRIT, "%s: %m", dir);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d] %s: %s", getpid(), dir, strerror(errno));
return 1;
}
}
if (!S_ISDIR(sbuf.st_mode))
{
- dprintf(("[%d] %s: not a directory\n", getpid(),dir));
- if (!debug) syslog(LOG_CRIT,"%s: not a directory",dir);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "[%d] %s: not a directory", getpid(),dir);
return 1;
}
if (access(dir, R_OK | W_OK))
{
- dprintf(("[%d] %s: directory is not readable/writable\n", getpid(),dir));
- if (!debug) syslog(LOG_CRIT,"%s: directory is not readable/writable",dir);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "[%d] %s: directory is not readable/writable", getpid(),dir);
return 1;
}
#include "glite/jobid/cjobid.h"
#include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
#include "glite/lb/context-int.h"
dbjob = edg_wlc_JobIdGetUnique(job);
trio_asprintf(&stmt,"select proxy,server from jobs where jobid = '%|Ss' for update",dbjob);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
ret = edg_wll_ExecSQL(ctx,stmt,&q);
if (ret <= 0) {
if (ret == 0) {
- fprintf(stderr,"%s: no such job\n",dbjob);
+ glite_common_log(LOG_CATEGORY_CONTROL,
+ LOG_PRIORITY_WARN, "%s: no such job",dbjob);
edg_wll_SetError(ctx,ENOENT,dbjob);
}
goto clean;
if (strcmp(res[1],"0")) result += DB_SERVER_JOB;
}
else {
- fprintf(stderr,"Error retrieving proxy&server fields of jobs table. Missing column?\n");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Error retrieving proxy&server fields of jobs table. Missing column?");
edg_wll_SetError(ctx,ENOENT,dbjob);
}
glite_lbu_FreeStmt(&q);
else
trio_asprintf(&stmt, "select * from jobs where jobid='%|Ss' lock in share mode", job);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if ((nr = edg_wll_ExecSQL(ctx,stmt,&sh)) < 0) goto cleanup;
if (nr == 0) {
char *err;
#include <unistd.h>
#include <stdio.h>
-
#include "glite/lbu/db.h"
#include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
extern int debug; // declared and set in bkserver.c
ret = edg_wll_Error(ctx,NULL,NULL);
if (ret == EDG_WLL_ERROR_DB_TRANS_DEADLOCK) {
- if (debug)
- printf("[%d]: DB deadlock detected. Rolling back transaction and retrying... \n",getpid());
- else
- syslog(LOG_INFO,"[%d]: DB deadlock detected. Rolling back transaction and retrying... \n",getpid());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ "[%d]: DB deadlock detected. Rolling back transaction "
+ "and retrying... \n", getpid());
edg_wll_ResetError(ctx);
return !edg_wll_Rollback(ctx);
}
if (ret == EDG_WLL_ERROR_DB_LOST_CONNECTION) {
- if (debug)
- printf("[%d]: Lost connection to DB. "
- "Rolling back transaction and retrying... \n",getpid());
- else
- syslog(LOG_INFO,"[%d]: Lost connection to DB. "
- "Rolling back transaction and retrying... \n",getpid());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ "[%d]: Lost connection to DB. "
+ "Rolling back transaction and retrying... \n",
+ getpid());
edg_wll_ResetError(ctx);
return !edg_wll_Rollback(ctx);
#include <time.h>
#include <stdio.h>
#include <string.h>
-#include <syslog.h>
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include "glite/lbu/trio.h"
#include "glite/jobid/cjobid.h"
+#include "glite/lbu/log.h"
#include "glite/lb/context-int.h"
#include "glite/lb/events_parse.h"
"order by arrived",
ctx->srvName,ctx->srvPort,
from_s,to_s);
-
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+
if (edg_wll_ExecSQL(ctx,stmt,&q) < 0) goto clean;
while ((ret = edg_wll_FetchRow(ctx,q,sizeof(res)/sizeof(res[0]),NULL,res)) > 0) {
* Must not be fatal -- just complain
*/
edg_wll_Error(ctx,&et,&ed);
- fprintf(stderr,"%s event %d: %s (%s)\n",res[1],event,et,ed);
- syslog(LOG_WARNING,"%s event %d: %s (%s)",res[1],event,et,ed);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "%s event %d: %s (%s)", res[1], event, et, ed);
free(et); free(ed);
for (i=0; i<sizofa(res); i++) free(res[i]);
edg_wll_ResetError(ctx);
#ident "$Header$"
-#include <syslog.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
+
#include "glite/lb/context-int.h"
#include "glite/lb/log_proto.h"
+#include "glite/lbu/log.h"
#include "il_lbproxy.h"
edg_wll_UpdateError(ctx, EDG_WLL_IL_PROTO, "edg_wll_log_event_send()");
edg_wll_Error(ctx, &errt, &errd);
- syslog(LOG_ERR,"%s (%s)", errt, errd);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "%s (%s)", errt, errd);
free(errt); free(errd);
_err(-1);
}
#include <string.h>
#include <errno.h>
#include <stdio.h>
-#include <syslog.h>
#include "glite/lbu/escape.h"
#include "glite/lb/context-int.h"
#include "glite/lb/notifid.h"
#include "glite/lb/events_parse.h"
#include "glite/lb/log_proto.h"
+#include "glite/lbu/log.h"
#include "il_notification.h"
#include "lb_xml_parse.h"
if(ret) edg_wll_UpdateError(context, ret, "edg_wll_NotifJobStatus()");
edg_wll_Error(context,&et,&ed);
- fprintf(stderr,"%s - %s\n", ed, et);
- syslog(LOG_INFO,"%s - %s\n", ed, et);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "%s - %s\n", ed, et);
edg_wll_ResetError(context);
free(et);
free(ed);
#include <assert.h>
#include <stdarg.h>
#include <regex.h>
-#include <syslog.h>
#include "glite/lbu/trio.h"
#include "glite/lb/events.h"
#include "glite/lb/context-int.h"
#include "glite/lb/intjobstat.h"
#include "glite/lb/process_event.h"
+#include "glite/lbu/log.h"
#include "get_events.h"
#include "store.h"
trio_asprintf(&stmt, "SELECT version,int_status,jobid FROM states WHERE parent_job='%|Ss'", md5_jobid);
if (stmt != NULL) {
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
num_sub = edg_wll_ExecSQL(ctx, stmt, &sh);
if (num_sub >=0 ) {
i = 0;
// Get child states from the database
trio_asprintf(&stmt, "SELECT version,status,jobid FROM states WHERE parent_job='%|Ss'", md5_jobid);
if (stmt != NULL) {
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
num_sub = edg_wll_ExecSQL(ctx, stmt, &sh);
if (num_sub >=0 ) {
while ((num_f = edg_wll_FetchRow(ctx, sh, sizeof(out_stat)/sizeof(out_stat[0]), NULL, out_stat)) == 3 ) {
"WHERE s.parent_job='%|Ss' AND s.jobid=j.jobid",
md5_jobid);
if (stmt != NULL) {
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
num_sub = edg_wll_ExecSQL(ctx, stmt, &sh);
if (num_sub >=0 ) {
while ((num_f = edg_wll_FetchRow(ctx, sh, sizeof(out)/sizeof(out[0]), NULL, out)) == 1 ) {
edg_wll_SetError(ctx,ENOMEM, NULL);
return NULL;
}
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&sh) >= 0) {
f=edg_wll_FetchRow(ctx,sh,1,NULL,&out);
if (f == 0) {
edg_wll_SetError(ctx,ENOMEM, NULL);
goto err;
}
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&sh) < 0) goto err;
"(jobid,seq,name,value) values "
"('%|Ss',%d,'%|Ss','%|Ss')",
jobid_md5, seq, (*tagp).tag, (*tagp).value);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, stmt);
+
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) {
if (EEXIST == edg_wll_Error(ctx, NULL, NULL)) {
/* XXX: this should not happen */
parent_md5, icvalues,
jobid_md5);
free(icvalues);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if ((dbret = edg_wll_ExecSQL(ctx,stmt,NULL)) < 0) goto cleanup;
free(stmt); stmt = NULL;
INTSTAT_VERSION, parent_md5, icvalues);
free(icnames); free(icvalues);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto cleanup;
free(stmt); stmt = NULL;
}
if (update) {
trio_asprintf(&stmt, "delete from status_tags "
"where jobid ='%|Ss' and seq<%d", jobid_md5, seq);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto cleanup;
free(stmt); stmt = NULL;
}
",parent_job%s) "
"values (%s)",
icnames, values);
-
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto cleanup;
cleanup:
if (stmt == NULL) {
return edg_wll_SetError(ctx, ENOMEM, NULL);
}
-
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+
if ((nstates = edg_wll_ExecSQL(ctx,stmt,&sh)) < 0) goto cleanup;
if (nstates == 0) {
edg_wll_SetError(ctx,ENOENT,"no state in DB");
if (stmt==NULL) {
return edg_wll_SetError(ctx,ENOMEM, NULL);
}
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&sh) >= 0) {
f=edg_wll_FetchRow(ctx,sh,1,NULL,&out);
}
//printf ("\n\n\n Would like to run SQL statament: %s\n\n\n\n", stmt);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if ((dbret = edg_wll_ExecSQL(ctx,stmt,NULL)) < 0) goto cleanup;
}
-
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <syslog.h>
#include "glite/lb/context-int.h"
#include "lb_authz.h"
+#include "glite/lbu/log.h"
#ifndef NO_VOMS
for ( ; ; )
{
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q1);
if ( edg_wll_ExecSQL(ctx, q1, NULL) > 0 )
goto end;
"update acls set refcnt = refcnt+%d "
"where aclid = '%|Ss'",
incr, aclid);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q2);
if ( edg_wll_ExecSQL(ctx, q2, NULL) < 0 )
continue;
"where aclid='%|Ss' and refcnt>=%d",
-incr, aclid, -incr);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q1);
if ( edg_wll_ExecSQL(ctx, q1, NULL) > 0 )
{
trio_asprintf(&q2,
"delete from acls "
"where aclid='%|Ss' and refcnt=0",
aclid);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q2);
edg_wll_ExecSQL(ctx, q2, NULL);
}
else
{
- fprintf(stderr, "ACL with ID: %s has invalid reference count\n", aclid);
- syslog(LOG_WARNING, "ACL with ID: %s has invalid reference count\n", aclid);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "ACL with ID: %s has invalid reference count", aclid);
}
}
trio_asprintf(&stmt,
"update jobs set aclid='%|Ss' where jobid='%|Ss' and ISNULL(aclid)",
new_aclid, md5_jobid);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, stmt);
updated = edg_wll_ExecSQL(ctx, stmt, NULL);
free(stmt); stmt = NULL;
trio_asprintf(&q,
"select aclid from jobs where jobid = '%|Ss'", jobstr);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q);
if (edg_wll_ExecSQL(ctx, q, &stmt) < 0 ||
edg_wll_FetchRow(ctx, stmt, 1, NULL, &acl_id) < 0) {
goto end;
trio_asprintf(&q,
"select value from acls where aclid = '%|Ss'", acl_id);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q);
if (edg_wll_ExecSQL(ctx, q, &stmt) < 0 ||
edg_wll_FetchRow(ctx, stmt, 1, NULL, &acl_str) < 0) {
goto end;
free(et); free(ed);
return out;
}
+
#include "glite/lb/mini_http.h"
#include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
+
#include "lb_http.h"
#include "lb_proto.h"
if ( ctx->isProxy ) err = edg_wll_http_recv_proxy(ctx,&req,&hdr,body);
else err = edg_wll_http_recv(ctx,&req,&hdr,body,ctx->connections->serverConnection);
- if (req) {
- dprintf(("[%d] request: %s\n",getpid(),req));
- } else {
- dprintf(("no request\n"));
- }
- if (body && *body) dprintf(("request body:\n%s\n\n",*body));
+ if (req)
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS,
+ LOG4C_PRIORITY_DEBUG, "[%d] request: %s",
+ getpid(), req);
+ else
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS,
+ LOG4C_PRIORITY_DEBUG, "no request");
+ if (body && *body)
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS,
+ LOG4C_PRIORITY_DEBUG, "request body:\n%s",*body);
if (!err) {
if ((err = edg_wll_Proto(ctx,req,hdr,*body,resp,hdrOut,bodyOut,httpErr)))
#include "glite/lb/xml_conversions.h"
#include "glite/jobid/strmd5.h"
#include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
#include "lb_proto.h"
#include "lb_text.h"
"from notif_registrations "
"where userid='%s'",
user);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
if (edg_wll_ExecSQL(ctx, q, ¬ifs) < 0) goto err;
free(q); q = NULL;
n++;
*notifids = realloc(*notifids, n*sizeof(**notifids));
(*notifids)[n-1] = strdup(notifc[n-1]);
- printf("Notif %s found\n", notifc[n-1]);
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "Notif %s found", notifc[n-1]);
}
if (n){
*notifids = realloc(*notifids, (n+1)*sizeof(**notifids));
"from notif_registrations "
"where notifid='%s'",
notifId);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
if (edg_wll_ExecSQL(ctx, q, ¬if) < 0) goto err;
free(q); q = NULL;
return edg_wll_Error(ctx,NULL,NULL);
}
+
#include <time.h>
#include <stdio.h>
#include <string.h>
-#include <syslog.h>
#include <assert.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
#include "glite/lb/context-int.h"
#include "glite/lb/events_parse.h"
total = 0,
written;
- fprintf(stderr, "Can't store event: %s\n", errdesc);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Can't store event: %s", errdesc);
if ( reject_fd == -1 )
{
char *s, *s1;
reject_fd = edg_wll_CreateFileStorage(ctx,FILE_TYPE_LOAD,NULL,&(result->server_file));
if ( reject_fd == -1 )
goto cycle_clean;
- printf("New reject file %s created\n", result->server_file);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "New reject file %s created", result->server_file);
free(s1);
}
/* Save the line into "reject_file"
i++;
}
}
+
#include "glite/lb/context-int.h"
#include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
#include "lb_authz.h"
#include "lb_xml_parse.h"
ju = edg_wlc_JobIdGetUnique(stat->jobId),NOTIF_ALL_JOBS,cond_where ? cond_where : "",cond_and_where ? cond_and_where : "");
free(ju); ju = NULL;
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, jobq);
if (edg_wll_ExecSQL(ctx,jobq,&jobs) < 0) goto err;
while ((ret = edg_wll_FetchRow(ctx,jobs,sizeof(jobc)/sizeof(jobc[0]),NULL,jobc)) > 0) {
if (now > (expires = glite_lbu_DBToTime(jobc[2]))) {
edg_wll_NotifExpired(ctx,jobc[0]);
- if (debug) fprintf(stderr,"[%d] NOTIFY:%s expired at %s UTC\n",
- getpid(),jobc[0],asctime(gmtime(&expires)));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "[%d] NOTIFY:%s expired at %s UTC",
+ getpid(),jobc[0],asctime(gmtime(&expires)));
}
else if (notif_match_conditions(ctx,oldstat,stat,jobc[4]) &&
notif_check_acl(ctx,stat,jobc[3]))
char *dest, *aux;
int port;
- if (debug) {
- fprintf(stderr,"NOTIFY: %s, job %s\n",jobc[0],
- ju = edg_wlc_JobIdGetUnique(stat->jobId));
- free(ju); ju = NULL;
- }
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "NOTIFY: %s, job %s", jobc[0], ju = edg_wlc_JobIdGetUnique(stat->jobId));
+ free(ju); ju = NULL;
dest = strdup(jobc[1]);
if ( !(aux = strchr(dest, ':')) )
trio_asprintf(&dn,"delete from notif_registrations where notifid='%|Ss'",notif);
trio_asprintf(&dj,"delete from notif_jobs where notifid='%|Ss'",notif);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, dn);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, dj);
if (edg_wll_ExecSQL(ctx,dn,NULL) < 0 ||
edg_wll_ExecSQL(ctx,dj,NULL) < 0)
char *et,*ed;
edg_wll_Error(ctx,&et,&ed);
- syslog(LOG_WARNING,"delete notification %s: %s (%s)",notif,et,ed);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "delete notification %s: %s (%s)", notif, et, ed);
free(et); free(ed);
}
if (!cond) return 1;
if (parseJobQueryRec(ctx,cond,strlen(cond),&c)) {
- fputs("notif_match_conditions(): parseJobQueryRec failed\n",stderr);
- syslog(LOG_ERR,"notif_match_conditions(): parseJobQueryRec failed");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "notif_match_conditions(): parseJobQueryRec failed");
+
return 1;
}
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
-#include <syslog.h>
#include <unistd.h>
#include "glite/jobid/strmd5.h"
#include "glite/lbu/trio.h"
#include "glite/lb/context-int.h"
#include "glite/lb/xml_parse.h"
+#include "glite/lbu/log.h"
#include "il_notification.h"
#include "query.h"
"values ('%|Ss','%|Ss',%s,'%|Ss', '<and>%|Ss</and>', '%d')",
nid_s, addr_s? addr_s: address_override, time_s, owner, xml_conds, flags);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+ q);
if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
goto rollback;
trio_asprintf(&q,
"insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')",
nid_s, jobs[i]);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q);
if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
goto rollback;
}
else {
trio_asprintf(&q,"insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')",
nid_s,NOTIF_ALL_JOBS);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q);
if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 ) goto rollback;
}
/* Format DB insert statement
*/
trio_asprintf(&q, "delete from notif_jobs where notifid='%|Ss'", nid_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, q);
if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
goto rollback;
trio_asprintf(&q,
"insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')",
nid_s, jobs[i]);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
{
/* XXX: Remove uncoplete registration?
*/
free(q);
trio_asprintf(&q, "delete from notif_jobs where notifid='%|Ss'", nid_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
edg_wll_ExecSQL(ctx, q, NULL);
free(q);
trio_asprintf(&q,"delete from notif_registrations where notifid='%|Ss'", nid_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
edg_wll_ExecSQL(ctx, q, NULL);
goto rollback;
}
}
can_peername = edg_wll_gss_normalize_subj(ctx->peerName, 0);
trio_asprintf(&q, "select userid from users where cert_subj='%|Ss'", can_peername);
- if ( edg_wll_ExecSQL(ctx, q, &stmt) < 0 )
- goto cleanup;
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
+ if ( edg_wll_ExecSQL(ctx, q, &stmt) < 0 )
+ goto cleanup;
/* returned value:
* 0 no user find - continue only when 'create' parameter is set
free(q);
trio_asprintf(&q, "insert into users(userid,cert_subj) values ('%|Ss','%|Ss')",
userid, can_peername);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
{
if ( edg_wll_Error(ctx,NULL,NULL) != EEXIST )
"select destination from notif_registrations "
"where notifid='%|Ss' and userid='%|Ss' FOR UPDATE",
nid_s, user);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if ( (ret = edg_wll_ExecSQL(ctx, stmt, &s)) < 0 )
goto cleanup;
free(stmt);
trio_asprintf(&stmt,
"select notifid from notif_registrations where notifid='%|Ss'", nid_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+ stmt);
ret = edg_wll_ExecSQL(ctx, stmt, NULL);
if ( ret == 0 )
edg_wll_SetError(ctx, ENOENT, "Unknown notification ID");
trio_asprintf(&aux, "%s where notifid='%|Ss'", stmt, nid_s);
free(stmt);
stmt = aux;
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG4C_PRIORITY_DEBUG, stmt);
if ( (ret = edg_wll_ExecSQL(ctx, stmt, NULL)) < 0 )
goto cleanup;
free(stmt);
trio_asprintf(&stmt,
"select notifid from notif_registrations where notifid='%|Ss'", nid_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG4C_PRIORITY_DEBUG, stmt);
ret = edg_wll_ExecSQL(ctx, stmt, NULL);
if ( ret == 0 )
edg_wll_SetError(ctx, ENOENT, "Unknown notification ID");
char *errt, *errd;
edg_wll_Error(ctx, &errt, &errd);
- fprintf(stderr,"edg_wll_NotifChangeIL(): %s (%s)\n", errt, errd);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "edg_wll_NotifChangeIL(): %s (%s)");
free(errt);
free(errd);
}
goto rollback;
trio_asprintf(&stmt, "delete from notif_registrations where notifid='%|Ss'", nid_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if ( edg_wll_ExecSQL(ctx, stmt, NULL) < 0 )
goto rollback;
free(stmt);
trio_asprintf(&stmt, "delete from notif_jobs where notifid='%|Ss'", nid_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if ( edg_wll_ExecSQL(ctx, stmt, NULL) < 0 )
goto rollback;
edg_wll_NotifCancelRegId(ctx, nid);
/* Let notification erase from DB,
* on notif-IL side it will be autopurged later anyway */
- fprintf(stderr,"[%d] edg_wll_NotifDropServer() - NotifID found and dropped,"\
- " however, connection to notif-IL was refused (notif-IL not running?)\n", getpid());
- syslog(LOG_INFO,"edg_wll_NotifDropServer() - NotifID found and dropped,"\
- " however, connection to notif-IL was refused (notif-IL not running?)");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "[%d] edg_wll_NotifDropServer() - NotifID found and " \
+ "dropped, however, connection to notif-IL was " \
+ " refused (notif-IL not running?)", getpid());
edg_wll_ResetError(ctx);
}
}
trio_asprintf(&q, "select notifid from notif_registrations WHERE notifid='%|Ss' AND valid < %s", nid_s, time_s);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
if ( (ret = edg_wll_ExecSQL(ctx, q, NULL)) < 0 )
goto cleanup;
free(time_s);
return edg_wll_Error(ctx, NULL, NULL);
}
+
#include "glite/lb/context-int.h"
#include "glite/lb/xml_conversions.h"
+#include "glite/lbu/log.h"
#include "get_events.h"
#include "index.h"
else if ( !q )
q = qbase;
-// printf("\nquery: %s\n\n", q);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+ q);
ret = edg_wll_ExecSQL(ctx, q, &sh);
if ( limit )
free(q);
else if ( !q )
q = qbase;
-// printf("\nquery: %s\n\n", q);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+ q);
ret = edg_wll_ExecSQL(ctx, q, &sh);
if ( limit )
free(q);
"(s.suffix_id = j.suffix_id) AND (p.prefix_id = j.prefix_id)) AS result "
"WHERE %s", zomb_where);
-
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, zquery);
j = edg_wll_ExecSQL(ctx,zquery,&sh);
if (j > 0) {
return 0;
}
+
#include "glite/lbu/trio.h"
#include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
#include "get_events.h"
#include "store.h"
if ( stmt == NULL ) return edg_wll_SetError(ctx, ENOMEM, NULL);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+
if ( (nstates = edg_wll_ExecSQL(ctx, stmt, &sh)) < 0 ) goto cleanup;
if ( nstates == 0 ) {
edg_wll_SetError(ctx, ENOENT, "no state in DB");
return edg_wll_Error(ctx, NULL, NULL);
}
+
#include "glite/lbu/trio.h"
#include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
#include "server_state.h"
#include "db_supp.h"
trio_asprintf(&stmt,"select value from server_state "
"where prefix = 'https://%|Ss:%d' and name = '%|Ss'",
ctx->srvName,ctx->srvPort,name);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
switch (edg_wll_ExecSQL(ctx,stmt,&q)) {
case 0: edg_wll_SetError(ctx,ENOENT,name); break;
trio_asprintf(&stmt,"insert into server_state (prefix,name,value) "
"values ('https://%|Ss:%d','%|Ss','%|Ss')",
ctx->srvName,ctx->srvPort,name,val);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
switch(edg_wll_ExecSQL(ctx,stmt,NULL)) {
case 1: break;
"where prefix = 'https://%|Ss:%d' "
"and name = '%|Ss'",
val,ctx->srvName,ctx->srvPort,name);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+ LOG_PRIORITY_DEBUG, stmt);
edg_wll_ExecSQL(ctx,stmt,NULL);
}
break;
#include "glite/jobid/cjobid.h"
#include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
+
#include "glite/lb/context-int.h"
#include "glite/lb/events_parse.h"
#include "glite/lb/mini_http.h"
for (jobs_to_exa=0; request->jobs[jobs_to_exa]; jobs_to_exa++);
for (i=0; request->jobs[i]; i++) {
if (edg_wlc_JobIdParse(request->jobs[i],&job)) {
- fprintf(stderr,"%s: parse error\n",request->jobs[i]);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "%s: parse error\n", request->jobs[i]);
parse = 1;
}
else {
if (check_strict_jobid(ctx,job)) {
- fprintf(stderr,"%s: not my job\n",request->jobs[i]);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "%s: not my job\n", request->jobs[i]);
parse = 1;
}
else {
}
else timeout[i] = request->timeout[i]; //specific given
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+ (ctx->isProxy)
+ ? "select dg_jobid from jobs where proxy='1'"
+ : "select dg_jobid from jobs where server='1'");
+
if ((jobs_to_exa = edg_wll_ExecSQL(ctx, (ctx->isProxy) ? "select dg_jobid from jobs where proxy='1'" :
"select dg_jobid from jobs where server='1'", &s)) < 0) goto abort;
while (edg_wll_FetchRow(ctx,s,1,NULL,&job_s) > 0) {
if (edg_wlc_JobIdParse(job_s,&job)) {
- fprintf(stderr,"%s: parse error (internal inconsistency !)\n",job_s);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "%s: parse error (internal inconsistency !)", job_s);
parse = 1;
}
else {
if (parse && !edg_wll_Error(ctx,NULL,NULL))
{
if ( naffected_jobs ) {
- fprintf(stderr,"[%d] Found some jobs not matching server address/port;"\
- " these were not purged but other jobs purged.\n", getpid());
- syslog(LOG_INFO,"Found some jobs not matching server address/port;"\
- " these were not purged but other jobs purged");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d] Found only jobs not matching server address/port; these were not purged.", getpid());
}
else {
- fprintf(stderr,"[%d] Found only jobs not matching server address/port;"\
- " these were not purged.\n", getpid());
- syslog(LOG_INFO,"Found only jobs not matching server address/port;"\
- " these were not purged.");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d] Found only jobs not matching server address/port; these were not purged.", getpid());
}
}
*/
edg_wll_Error(ctx,&et,&ed);
dbjob = edg_wlc_JobIdGetUnique(job);
- fprintf(stderr,"%s event %d: %s (%s)\n",dbjob,event,et,ed);
- syslog(LOG_WARNING,"%s event %d: %s (%s)",dbjob,event,et,ed);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "%s event %d: %s (%s)", dbjob, event, et, ed);
free(et); free(ed); free(dbjob);
edg_wll_ResetError(ctx);
}
while (total != len) {
written = write(dump,event_s+total,len-total);
if (written < 0 && errno != EAGAIN) {
- perror("dump to file");
- syslog(LOG_ERR,"dump to file: %m");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "dump to file");
dump = -1; /* XXX: likely to be a permanent error
* give up writing but do purge */
break;
if ( purge )
{
trio_asprintf(&stmt,"delete from jobs where jobid = '%|Ss'",dbjob);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto rollback;
free(stmt); stmt = NULL;
trio_asprintf(&stmt,"delete from states where jobid = '%|Ss'",dbjob);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto rollback;
free(stmt); stmt = NULL;
}
if ( purge )
{
trio_asprintf(&stmt,"delete from status_tags where jobid = '%|Ss'",dbjob);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto rollback;
free(stmt); stmt = NULL;
}
// See if that prefix is already stored in the database
trio_asprintf(&stmt,"select prefix_id from zombie_prefixes where prefix = '%|Ss'", prefix);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
sql_retval = edg_wll_ExecSQL(ctx,stmt,&q);
free(stmt); stmt = NULL;
glite_lbu_FreeStmt(&q);
trio_asprintf(&stmt,"insert into zombie_prefixes (prefix) VALUES ('%|Ss')", prefix);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
// The record should exist now, however we need to look up the prefix_id
trio_asprintf(&stmt,"select prefix_id from zombie_prefixes where prefix = '%|Ss'", prefix);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
free(stmt); stmt = NULL;
// See if that suffix is already stored in the database
trio_asprintf(&stmt,"select suffix_id from zombie_suffixes where suffix = '%|Ss'", suffix);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
sql_retval = edg_wll_ExecSQL(ctx,stmt,&q);
free(stmt); stmt = NULL;
glite_lbu_FreeStmt(&q);
trio_asprintf(&stmt,"insert into zombie_suffixes (suffix) VALUES ('%|Ss')", suffix);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
// The record should exist now, however we need to look up the suffix_id
trio_asprintf(&stmt,"select suffix_id from zombie_suffixes where suffix = '%|Ss'", suffix);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
free(stmt); stmt = NULL;
trio_asprintf(&stmt,"insert into zombie_jobs (jobid, prefix_id, suffix_id)"
" VALUES ('%|Ss', '%|Ss', '%|Ss')", root, prefix_id, suffix_id);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
if (edg_wll_ExecSQL(ctx,stmt,&q) < 0) {
if (edg_wll_Error(ctx, NULL, NULL) == EEXIST) {
asprintf(&msg,"Warning: erasing job %s that already existed in this LB "
"(reused jobid or corruped DB) (%s: %s)",job_s,et,ed);
- fprintf(stderr,"[%d] %s\n", getpid(), msg);
- syslog(LOG_INFO,msg);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d] %s\n", getpid(), msg);
free(et); free(ed); free(msg); free(job_s);
edg_wll_ResetError(ctx);
}
"where jobid='%|Ss' "
"order by event", dbjob);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+
if (edg_wll_ExecSQL(ctx,stmt,&q) < 0) goto rollback;
free(stmt); stmt = NULL;
dbjob = glite_jobid_getUnique(job);
trio_asprintf(&stmt,"update jobs set proxy='0' where jobid='%|Ss'", dbjob);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
free(dbjob);
return(edg_wll_ExecSQL(ctx,stmt,NULL));
dbjob = glite_jobid_getUnique(job);
trio_asprintf(&stmt,"update jobs set server='0' where jobid='%|Ss'", dbjob);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
free(dbjob);
return(edg_wll_ExecSQL(ctx,stmt,NULL));
}
}
+
#include "glite/lb/jobstat.h"
#include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
+
#include "glite/jobid/strmd5.h"
#include "stats.h"
stats[i].map = mmap(NULL,sizeof zero,PROT_READ|PROT_WRITE,MAP_SHARED,stats[i].fd,0);
if (stats[i].map == MAP_FAILED) return edg_wll_SetError(ctx,errno,"mmap()");
- dprintf(("stats: using %s\n",fname));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "stats: using %s",fname);
unlink(fname);
}
return 0;
if (!jobstat->destination) return 0;
edg_wll_ResetError(ctx);
- dprintf(("inc_counter: destination %s, stats %d\n",jobstat->destination,
- (int) (stats - (edg_wll_Stats *) default_stats)));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "inc_counter: destination %s, stats %d\n",
+ jobstat->destination, (int) (stats - (edg_wll_Stats *) default_stats));
if (flock(stats->fd,LOCK_EX)) return edg_wll_SetError(ctx,errno,"flock()");
/* not found, initialize new */
if (i == stats->grpno) {
- dprintf(("group %s not found\n",sig));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "group %s not found",sig);
if (stats->grpno) {
char *zero = calloc(1,stats->grpsize);
munmap(stats->map,stats->grpno * stats->grpsize);
}
stats->grpno++;
stats->map->grpno++;
- dprintf(("allocated\n"));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "allocated");
g = (struct edg_wll_stats_group *) (
((char *) stats->map) + stats->grpsize * i);
strcpy(g->sig,sig);
g->last_update = now;
}
- else dprintf(("group %s found at %d\n",sig,i));
+ else
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "group %s found at %d", sig, i);
a = g->archive;
for (i=0; stats->archives[i].interval; i++) {
/* now we can do IT */
a->cells[a->ptr].cnt++;
- dprintf(("update archive %d, cell %d to %d\n",i,a->ptr,a->cells[a->ptr].cnt));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "update archive %d, cell %d to %d",
+ i, a->ptr, a->cells[a->ptr].cnt);
/* go to next archive */
a = archive_skip(a,stats->archives[i].length);
}
}
- dprintf(("best match: archive %d, interval %ld\n",matchi,match));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "best match: archive %d, interval %ld", matchi, match);
if (matchi < 0) {
if (*from > g->last_update) {
afrom = g->last_update - g->last_update % i
- (stats->archives[matchi].length-1)*i;
- dprintf(("archive from %ld = %s",afrom,ctime(&afrom)));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "archive from %ld = %s", afrom, ctime(&afrom));
if (afrom > *from) *from = afrom;
if (afrom + stats->archives[matchi].length * i < *to) *to = afrom + stats->archives[matchi].length * i;
for (j=0; j<stats->archives[matchi].length; j++,afrom += i) {
struct edg_wll_stats_cell *c = a->cells + ((a->ptr+j+1) % stats->archives[matchi].length);
- dprintf(("cell %d (abs %d): ",j,(a->ptr+j+1) % stats->archives[matchi].length));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "cell %d (abs %d): ",
+ j, (a->ptr+j+1) % stats->archives[matchi].length);
if (c->cnt < 0) {
- dprintf(("invalid\n"));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "invalid");
continue; /* invalid cell */
}
- dprintf(("search %ld in %ld, %ld\n",*from,afrom,afrom+i));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+ "search %ld in %ld, %ld\n", *from, afrom, afrom+i);
if (*from >= afrom && *from < afrom+i) {
match += *from - afrom;
*rate += c->cnt * (1.0 - ((float) *from-afrom)/i);
- dprintf(("matched from: match %ld, rate %f\n",match,*rate));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "matched from: match %ld, rate %f", match, *rate);
}
else if (*from < afrom && *to >= afrom) {
match += i;
*rate += c->cnt;
- dprintf(("matched in: match %ld, rate %f\n",match,*rate));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "matched in: match %ld, rate %f", match, *rate);
}
if (*to >= afrom && *to < afrom+i) {
match -= i-(*to-afrom);
*rate -= c->cnt * (((float) i)-(*to - afrom))/i;
- dprintf(("matched to: match %ld, rate %f\n",match,*rate));
+ glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "matched to: match %ld, rate %f", match, *rate);
/* asi blbost
if (j == stats->archives[matchi].length - 1
#include "glite/jobid/strmd5.h"
#include "glite/lbu/trio.h"
#include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
#include "jobstat.h"
#include "db_supp.h"
free(can_peername);
trio_asprintf(&stmt,"select cert_subj from users where userid = '%|Ss'",userid);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
switch (edg_wll_ExecSQL(ctx,stmt,&sth)) {
case 0: edg_wll_SetError(ctx,ENOENT,ctx->peerName);
free(res); res = NULL;
trio_asprintf(&stmt,"select dg_jobid from jobs where userid = '%|Ss' and grey='0'",userid);
+ glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
switch (njobs = edg_wll_ExecSQL(ctx,stmt,&sth)) {
case 0: edg_wll_SetError(ctx,ENOENT,ctx->peerName);
case -1: goto err;
return err;
}
+
#include "glite/lb/xml_parse.h"
#include "glite/lb/xml_conversions.h"
+#include "glite/lbu/log.h"
#include "soap_version.h"
#include "glite/security/glite_gsplugin.h"
struct _lbe__GetVersion *in,
struct _lbe__GetVersionResponse *out)
{
- dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+ "[%d] WS call %s", getpid(), __FUNCTION__);
out->version = soap_strdup(soap, VERSION);
int flags;
- dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+ "[%d] WS call %s", getpid(), __FUNCTION__);
if ( edg_wlc_JobIdParse(in->jobid, &j) )
{
cjobid = edg_wlc_JobIdUnparse(j);
cflags = edg_wll_stat_flags_to_string(flags);
- dprintf(("[%d] \n\t<flags>%s</flags>\n\t<jobId>%s</jobId>\n\n",getpid(),cflags,cjobid));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS,
+ LOG_PRIORITY_DEBUG,
+ "[%d] \n\t<flags>%s</flags>\n\t<jobId>%s</jobId>\n",
+ getpid(), cflags, cjobid);
free(cjobid);
free(cflags);
}
int ret = SOAP_FAULT;
- dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+ "[%d] WS call %s", getpid(), __FUNCTION__);
out->states = soap_malloc(soap, sizeof(*out->states));
out->jobs = soap_malloc(soap, sizeof(*out->jobs));
if (edg_wll_QueryJobsRequestToXML(ctx,
(const edg_wll_QueryRec **) conditions,
flags, &message)) {
- dprintf(("[%d] %s\n",getpid(),"edg_wll_QueryJobsRequestToXML() returned error"));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] %s", getpid(), "edg_wll_QueryJobsRequestToXML() returned error");
}
else {
- dprintf(("[%d] \n%s\n\n",getpid(),message));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] \n%s\n", getpid(), message);
}
free(message);
}
edg_wll_JobStat *states;
- dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+ "[%d] WS call %s", getpid(), __FUNCTION__);
ctx = (edg_wll_Context) glite_gsplugin_get_udata(soap);
memset(out, 0, sizeof *out);
int ret = SOAP_OK;
- dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+ "[%d] WS call %s", getpid(), __FUNCTION__);
edg_wll_ResetError(ctx);
if ( edg_wll_SoapToQueryCondsExt(in->jobConditions, in->__sizejobConditions,
(const edg_wll_QueryRec **) job_conditions,
(const edg_wll_QueryRec **) event_conditions,
&message)) {
- dprintf(("[%d] %s\n",getpid(),"edg_wll_QueryEventsRequestToXML() returned error"));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] %s", getpid(), "edg_wll_QueryEventsRequestToXML() returned error");
}
else {
- dprintf(("[%d] \n%s\n\n",getpid(),message));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] \n%s\n", getpid(), message);
}
free(message);
}
edg_wll_NotifId nid = NULL;
int ret = SOAP_OK;
- dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+ glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+ "[%d] WS call %s\n", getpid(), __FUNCTION__);
edg_wll_ResetError(ctx);
if ( edg_wll_SoapToQueryCondsExt(in->conditions, in->__sizeconditions, &conditions) )
free(events);
}
}
+