#include "interlogd.h"
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+#define il_strerror_r strerror_r
+#else
+#define il_strerror_r(a,b,c) if(1) { char *p = strerror_r((a), (b), (c)); if(p && p != (b)) { int len = strlen(p); memset((b), 0, (c)); strncpy((b), p, len > (c) ? (c) : len); } }
+#endif
+
#ifdef __GNUC__
#define UNUSED_VAR __attribute__((unused))
#else
/* check the file modification time and size to avoid unnecessary operations */
memset(&stbuf, 0, sizeof(stbuf));
if(fstat(fd, &stbuf) < 0) {
+ il_strerror_r(errno, err_msg, sizeof(err_msg));
glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_ERROR,
" could not stat event file %s: %s",
- es->event_file_name, strerror(errno));
+ es->event_file_name, err_msg);
fclose(ef);
event_store_unlock(es);
if(pthread_rwlock_unlock(&es->offset_lock))
int fd;
FILE *ef;
struct flock efl;
+ char buf[256];
assert(es != NULL);
event_store_unlock(es);
if(pthread_rwlock_unlock(&es->offset_lock))
abort();
+ il_strerror_r(errno, buf, sizeof(buf));
glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_ERROR,
- " event_store_clean: error opening event file: %s", strerror(errno));
+ " event_store_clean: error opening event file: %s", buf);
return(1);
}
int
event_store_init(char *prefix)
{
+ char buf[256];
+
if(file_prefix == NULL) {
file_prefix = strdup(prefix);
store_list = NULL;
DIR *event_dir;
struct dirent *entry;
-
/* get directory name */
p = strrchr(file_prefix, '/');
if(p == NULL) {
strcat(ef, s);
glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_DEBUG,
" removing stale file %s", ef);
- if(unlink(ef))
+ if(unlink(ef)) {
+ il_strerror_r(errno, buf, sizeof(buf));
glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_ERROR,
- " could not remove file %s: %s\n", ef, strerror(errno));
-
+ " could not remove file %s: %s\n", ef, buf);
+ }
}
free(ef);
#include "glite/security/glite_gss.h"
#include "il_error.h"
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+#define il_strerror_r strerror_r
+#else
+#define il_strerror_r(a,b,c) if(1) { char *p = strerror_r((a), (b), (c)); if(p && p != (b)) { int len = strlen(p); memset((b), 0, (c)); strncpy((b), p, len > (c) ? (c) : len); } }
+#endif
static pthread_key_t err_key;
set_error(int code, long minor, char *msg)
{
struct error_inf *err;
+ char buf[256];
err = error_get_err();
switch(code) {
case IL_SYS:
- snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, strerror(err->code_min));
+ *buf = 0;
+ il_strerror_r(err->code_min, buf, sizeof(buf));
+ snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, buf);
break;
case IL_HOST:
break;
case EDG_WLL_GSS_ERROR_ERRNO:
- snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, strerror(errno));
+ *buf = 0;
+ il_strerror_r(errno, buf, sizeof(buf));
+ snprintf(err->msg, IL_ERR_MSG_LEN, "%s: %s", msg, buf);
break;
case EDG_WLL_GSS_ERROR_HERRNO:
#include "glite/lb/lb_perftest.h"
#endif
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+#define il_strerror_r strerror_r
+#else
+#define il_strerror_r(a,b,c) if(1) { char *p = strerror_r((a), (b), (c)); if(p && p != (b)) { int len = strlen(p); memset((b), 0, (c)); strncpy((b), p, len > (c) ? (c) : len); } }
+#endif
+
int
enqueue_msg(struct event_queue *eq, struct server_msg *msg)
/* global: parallel */
while(num_replies < num_threads) {
int ret;
if((ret=pthread_cond_timedwait(&flush_cond, &flush_lock, &endtime)) < 0) {
+ char buf[256];
+
+ il_strerror_r(errno, buf, sizeof(buf));
glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_ERROR,
" error waiting for thread reply: %s",
- strerror(errno));
+ buf);
result = (ret == ETIMEDOUT) ? 0 : -1;
break;
}
edg_wll_GssCred newcred;
case 0: break;
case 1:
- ret = edg_wll_gss_acquire_cred(cert_file,key_file,GSS_C_ACCEPT, &newcred,&gss_stat);
+ ret = edg_wll_gss_acquire_cred(cert_file,key_file, GSS_C_ACCEPT, &newcred,&gss_stat);
if (ret) {
glite_common_log(LOG_CATEGORY_SECURITY,LOG_PRIORITY_WARN,"Reloading credentials failed, continue with older\n");
} else {
#include <signal.h>
#include <unistd.h>
#include <sys/param.h>
+#include <string.h>
#include "interlogd.h"
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+#define il_strerror_r strerror_r
+#else
+#define il_strerror_r(a,b,c) if(1) { char *p = strerror_r((a), (b), (c)); if(p && p != (b)) { int len = strlen(p); memset((b), 0, (c)); strncpy((b), p, len > (c) ? (c) : len); } }
+#endif
+
static
void
queue_thread_cleanup(void *q)
event_queue_write_stat(struct event_queue *eq) {
FILE *statfile;
char fn[MAXPATHLEN];
+ char buf[256];
snprintf(fn, sizeof(fn), "%s.%s.stat", file_prefix, eq->dest_name);
statfile = fopen(fn, "w");
if(NULL == statfile) {
+ il_strerror_r(errno, buf, sizeof(buf));
glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_WARN,
"Error opening destination stat file %s: %s",
- fn, strerror(errno));
+ fn, buf);
return;
}
if(fprintf(statfile, "last_connected=%ld\nlast_sent=%ld\n",
eq->last_connected,
eq->last_sent) < 0) {
+ il_strerror_r(errno, buf, sizeof(buf));
glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_WARN,
"Error writing destination statistics into %s: %s",
- fn, strerror(errno));
+ fn, buf);
}
fclose(statfile);
}