MXS-251: strerror
Replaces all calls to strerror with calls to strerror_r. The former is non-thread safe while the latter is.
This commit is contained in:
parent
a9fd7926ac
commit
160bbb70ee
@ -55,6 +55,13 @@
|
||||
#include <histedit.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We need a common.h file that is included by every component.
|
||||
*/
|
||||
#if !defined(STRERROR_BUFLEN)
|
||||
#define STRERROR_BUFLEN 512
|
||||
#endif
|
||||
|
||||
static int connectMaxScale(char *hostname, char *port);
|
||||
static int setipaddress(struct in_addr *a, char *p);
|
||||
static int authMaxScale(int so, char *user, char *password);
|
||||
@ -329,8 +336,9 @@ int keepalive = 1;
|
||||
|
||||
if ((so = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Unable to create socket: %s\n",
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return -1;
|
||||
}
|
||||
memset(&addr, 0, sizeof addr);
|
||||
@ -339,8 +347,9 @@ int keepalive = 1;
|
||||
addr.sin_port = htons(atoi(port));
|
||||
if (connect(so, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Unable to connect to MaxScale at %s, %s: %s\n",
|
||||
hostname, port, strerror(errno));
|
||||
hostname, port, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
close(so);
|
||||
return -1;
|
||||
}
|
||||
|
@ -2217,12 +2217,13 @@ static bool logfile_open_file(
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Error : writing to file %s failed due to %d, %s. "
|
||||
"Exiting MaxScale.\n",
|
||||
lf->lf_full_file_name,
|
||||
err,
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
succp = false;
|
||||
goto return_succp;
|
||||
}
|
||||
@ -2433,20 +2434,22 @@ static bool check_file_and_path(
|
||||
|
||||
if (do_log && file_is_symlink(filename))
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access "
|
||||
"file pointed to by %s due "
|
||||
"to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else if (do_log)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access %s due "
|
||||
"to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
|
||||
if(writable)
|
||||
@ -2954,6 +2957,7 @@ static void* thr_filewriter_fun(
|
||||
do_flushall));
|
||||
if (err)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Error : Write to %s log "
|
||||
": %s failed due to %d, "
|
||||
@ -2961,7 +2965,7 @@ static void* thr_filewriter_fun(
|
||||
STRLOGNAME((logfile_id_t)i),
|
||||
lf->lf_full_file_name,
|
||||
err,
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
/** Force log off */
|
||||
skygw_log_disable_raw((logfile_id_t)i, true);
|
||||
}
|
||||
|
@ -18,6 +18,13 @@
|
||||
#if !defined(LOG_MANAGER_H)
|
||||
# define LOG_MANAGER_H
|
||||
|
||||
/*
|
||||
* We need a common.h file that is included by every component.
|
||||
*/
|
||||
#if !defined(STRERROR_BUFLEN)
|
||||
#define STRERROR_BUFLEN 512
|
||||
#endif
|
||||
|
||||
typedef struct filewriter_st filewriter_t;
|
||||
typedef struct logfile_st logfile_t;
|
||||
typedef struct fnames_conf_st fnames_conf_t;
|
||||
|
@ -358,10 +358,11 @@ int main(int argc, char** argv)
|
||||
"set.\n");
|
||||
ss_dassert(workingdir != NULL);
|
||||
} else if (access(workingdir, R_OK) != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Failed to access the working directory due %d, %s\n",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
ss_dassert(false);
|
||||
} else {
|
||||
char** so = server_options;
|
||||
|
@ -113,10 +113,11 @@ SHARED_BUF *sbuf;
|
||||
retblock:
|
||||
if (rval == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
@ -182,10 +183,11 @@ GWBUF *rval;
|
||||
if ((rval = (GWBUF *)calloc(1,sizeof(GWBUF))) == NULL)
|
||||
{
|
||||
ss_dassert(rval != NULL);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -246,10 +248,11 @@ GWBUF *gwbuf_clone_portion(
|
||||
if ((clonebuf = (GWBUF *)malloc(sizeof(GWBUF))) == NULL)
|
||||
{
|
||||
ss_dassert(clonebuf != NULL);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
atomic_add(&buf->sbuf->refcount, 1);
|
||||
@ -500,10 +503,11 @@ void gwbuf_add_buffer_object(
|
||||
|
||||
if (newb == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return;
|
||||
}
|
||||
newb->bo_id = id;
|
||||
@ -590,11 +594,11 @@ BUF_PROPERTY *prop;
|
||||
if ((prop = malloc(sizeof(BUF_PROPERTY))) == NULL)
|
||||
{
|
||||
ss_dassert(prop != NULL);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 0;
|
||||
}
|
||||
prop->name = strdup(name);
|
||||
|
@ -907,12 +907,13 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
users_data = (char *)calloc(nusers, (users_data_row_len * sizeof(char)) + 1);
|
||||
|
||||
if (users_data == NULL) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"%d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
@ -1416,12 +1417,13 @@ getUsers(SERVICE *service, USERS *users)
|
||||
users_data = (char *)calloc(nusers, (users_data_row_len * sizeof(char)) + 1);
|
||||
|
||||
if (users_data == NULL) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"%d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
@ -2471,4 +2473,4 @@ bool check_service_permissions(SERVICE* service)
|
||||
mysql_close(mysql);
|
||||
free(dpasswd);
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
|
@ -545,6 +545,7 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_process_victim_queue] Error : Failed to close "
|
||||
@ -553,7 +554,7 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
dcb->fd,
|
||||
dcb,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -789,6 +790,7 @@ int dcb_read(
|
||||
|
||||
if (-1 == ioctl(dcb->fd, FIONREAD, &bytesavailable))
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -799,7 +801,7 @@ int dcb_read(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/* </editor-fold> */
|
||||
return -1;
|
||||
}
|
||||
@ -839,6 +841,7 @@ int dcb_read(
|
||||
* This is a fatal error which should cause shutdown.
|
||||
* Todo shutdown if memory allocation fails.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -848,7 +851,7 @@ int dcb_read(
|
||||
dcb,
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/* </editor-fold> */
|
||||
return -1;
|
||||
}
|
||||
@ -859,6 +862,7 @@ int dcb_read(
|
||||
{
|
||||
if (errno != 0 && errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -869,7 +873,7 @@ int dcb_read(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/* </editor-fold> */
|
||||
}
|
||||
gwbuf_free(buffer);
|
||||
@ -935,6 +939,7 @@ int dcb_read_SSL(
|
||||
pending = SSL_pending(dcb->ssl);
|
||||
if (rc == -1)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : ioctl FIONREAD for dcb %p in "
|
||||
@ -943,7 +948,7 @@ int dcb_read_SSL(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
n = -1;
|
||||
goto return_n;
|
||||
}
|
||||
@ -996,6 +1001,7 @@ int dcb_read_SSL(
|
||||
* This is a fatal error which should cause shutdown.
|
||||
* Todo shutdown if memory allocation fails.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to allocate read buffer "
|
||||
@ -1003,7 +1009,7 @@ int dcb_read_SSL(
|
||||
dcb,
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
n = -1;
|
||||
goto return_n;
|
||||
@ -1038,6 +1044,7 @@ int dcb_read_SSL(
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Read failed, dcb %p in state "
|
||||
@ -1046,7 +1053,7 @@ int dcb_read_SSL(
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
ssl_errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
if(ssl_errno == SSL_ERROR_SSL ||
|
||||
ssl_errno == SSL_ERROR_SYSCALL)
|
||||
@ -1321,6 +1328,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
{
|
||||
if (eno == EPIPE)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Write to dcb "
|
||||
@ -1331,7 +1339,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1341,6 +1349,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
eno != EAGAIN &&
|
||||
eno != EWOULDBLOCK)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write to dcb %p in "
|
||||
@ -1350,7 +1359,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
}
|
||||
|
||||
@ -1376,13 +1385,14 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
}
|
||||
if (dolog)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
||||
pthread_self(),
|
||||
dcb_isclient(dcb) ? "client" : "backend server",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1497,7 +1507,7 @@ static int
|
||||
dcb_write_SSL_error_report (DCB *dcb, int ret)
|
||||
{
|
||||
int ssl_errno;
|
||||
char errbuf[256];
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ssl_errno = SSL_get_error(dcb->ssl,ret);
|
||||
|
||||
if (LOG_IS_ENABLED(LOGFILE_DEBUG))
|
||||
@ -1557,9 +1567,7 @@ dcb_write_SSL_error_report (DCB *dcb, int ret)
|
||||
{
|
||||
if(ssl_errno == SSL_ERROR_SYSCALL)
|
||||
{
|
||||
strerror_r(errno,errbuf,255);
|
||||
errbuf[255] = '\0';
|
||||
skygw_log_write(LE,"%d:%s",errno,errbuf);
|
||||
skygw_log_write(LE,"%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
do
|
||||
{
|
||||
@ -1630,6 +1638,7 @@ int above_water;
|
||||
{
|
||||
break;
|
||||
}
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write to dcb %p "
|
||||
@ -1638,7 +1647,7 @@ int above_water;
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
saved_errno,
|
||||
strerror(saved_errno))));
|
||||
strerror_r(saved_errno, errbuf, sizeof(errbuf)))));
|
||||
break;
|
||||
}
|
||||
/*
|
||||
@ -1734,7 +1743,10 @@ dcb_drain_writeq_SSL(DCB *dcb)
|
||||
skygw_log_write(LE,"%s",errbuf);
|
||||
}
|
||||
if(errno != 0)
|
||||
skygw_log_write(LE,"%d:%s",errno,strerror(errno));
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LE,"%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
break;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
skygw_log_write(LE,"Socket is closed.");
|
||||
|
@ -147,8 +147,9 @@ int externcmd_execute(EXTERNCMD* cmd)
|
||||
|
||||
if(pid < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error: Failed to execute command '%s', fork failed: [%d] %s",
|
||||
cmd->parameters[0],errno,strerror(errno));
|
||||
cmd->parameters[0],errno,strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
rval = -1;
|
||||
}
|
||||
else if(pid == 0)
|
||||
|
@ -349,12 +349,13 @@ DOWNSTREAM *me;
|
||||
}
|
||||
if ((me = (DOWNSTREAM *)calloc(1, sizeof(DOWNSTREAM))) == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for filter session failed "
|
||||
"due to %d,%s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -351,10 +351,9 @@ sigchld_handler (int i)
|
||||
|
||||
if((child = wait(&exit_status)) == -1)
|
||||
{
|
||||
char errbuf[512];
|
||||
strerror_r(errno,errbuf,511);
|
||||
errbuf[511] = '\0';
|
||||
skygw_log_write_flush(LE,"Error: failed to wait child process: %d %s",errno,errbuf);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(LE,"Error: failed to wait child process: %d %s",
|
||||
errno,strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -456,12 +455,13 @@ static int signal_set (int sig, void (*handler)(int)) {
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed call sigaction() in %s due to %d, %s.",
|
||||
program_invocation_short_name,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
@ -484,14 +484,14 @@ int ntfw_cb(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to remove the data directory %s of "
|
||||
"MaxScale due to %d, %s.",
|
||||
datadir,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -785,21 +785,23 @@ static void print_log_n_stderr(
|
||||
char* fpr_end = "\n*\n";
|
||||
|
||||
if (do_log) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%s %s %s %s",
|
||||
log_err,
|
||||
logstr,
|
||||
eno == 0 ? " " : "Error :",
|
||||
eno == 0 ? " " : strerror(eno))));
|
||||
eno == 0 ? " " : strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
if (do_stderr) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"%s %s %s %s %s",
|
||||
fpr_err,
|
||||
fprstr,
|
||||
eno == 0 ? " " : "Error :",
|
||||
eno == 0 ? " " : strerror(eno),
|
||||
eno == 0 ? " " : strerror_r(eno, errbuf, sizeof(errbuf)),
|
||||
fpr_end);
|
||||
}
|
||||
}
|
||||
@ -813,6 +815,7 @@ static bool file_is_readable(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
if (!daemon_mode)
|
||||
{
|
||||
@ -820,7 +823,7 @@ static bool file_is_readable(
|
||||
"*\n* Warning : Failed to read the configuration "
|
||||
"file %s. %s.\n*\n",
|
||||
absolute_pathname,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -828,7 +831,7 @@ static bool file_is_readable(
|
||||
"to %d, %s.",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
LOGIF(LE,(skygw_log_sync_all()));
|
||||
succp = false;
|
||||
}
|
||||
@ -844,6 +847,7 @@ static bool file_is_writable(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
if (!daemon_mode)
|
||||
{
|
||||
@ -852,7 +856,7 @@ static bool file_is_writable(
|
||||
"due %d, %s.\n*\n",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -860,7 +864,7 @@ static bool file_is_writable(
|
||||
"to %d, %s.",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
succp = false;
|
||||
}
|
||||
return succp;
|
||||
@ -907,13 +911,14 @@ static char* get_expanded_pathname(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
fprintf(stderr,
|
||||
"*\n* Warning : Failed to read the "
|
||||
"directory %s. %s.\n*\n",
|
||||
relative_path,
|
||||
strerror(eno));
|
||||
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Warning : Failed to read the "
|
||||
@ -921,7 +926,7 @@ static char* get_expanded_pathname(
|
||||
"to %d, %s.",
|
||||
relative_path,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
free(expanded_path);
|
||||
*output_path = NULL;
|
||||
goto return_cnf_file_buf;
|
||||
@ -942,11 +947,12 @@ static char* get_expanded_pathname(
|
||||
if (cnf_file_buf == NULL)
|
||||
{
|
||||
ss_dassert(cnf_file_buf != NULL);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
free(expanded_path);
|
||||
expanded_path = NULL;
|
||||
@ -1707,8 +1713,10 @@ int main(int argc, char **argv)
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
if(errno != EEXIST){
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
"Error: Cannot create data directory '%s': %d %s\n",
|
||||
datadir, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
@ -1718,8 +1726,10 @@ int main(int argc, char **argv)
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
if(errno != EEXIST){
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
"Error: Cannot create data directory '%s': %d %s\n",
|
||||
datadir, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
@ -2059,11 +2069,12 @@ static void unlink_pidfile(void)
|
||||
if (strlen(pidfile)) {
|
||||
if (unlink(pidfile))
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"MaxScale failed to remove pidfile %s: error %d, %s\n",
|
||||
pidfile,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2426,32 +2437,36 @@ static int set_user(char* user)
|
||||
pwname = getpwnam(user);
|
||||
if(pwname == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to retrieve user information for '%s': %d %s\n",
|
||||
user,errno,errno == 0 ? "User not found" : strerror(errno));
|
||||
user,errno,errno == 0 ? "User not found" : strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
rval = setgid(pwname->pw_gid);
|
||||
if(rval != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to change group to '%d': %d %s\n",
|
||||
pwname->pw_gid,errno,strerror(errno));
|
||||
pwname->pw_gid, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return rval;
|
||||
}
|
||||
|
||||
rval = setuid(pwname->pw_uid);
|
||||
if(rval != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to change user to '%s': %d %s\n",
|
||||
pwname->pw_name,errno,strerror(errno));
|
||||
pwname->pw_name, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return rval;
|
||||
}
|
||||
if(prctl(PR_GET_DUMPABLE) == 0)
|
||||
{
|
||||
if(prctl(PR_SET_DUMPABLE ,1) == -1)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error: Failed to set dumpable flag on for the process '%s': %d %s\n",
|
||||
pwname->pw_name,errno,strerror(errno));
|
||||
pwname->pw_name, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,8 @@ void gw_daemonize(void) {
|
||||
pid = fork();
|
||||
|
||||
if (pid < 0) {
|
||||
fprintf(stderr, "fork() error %s\n", strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "fork() error %s\n", strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -157,7 +158,8 @@ void gw_daemonize(void) {
|
||||
}
|
||||
|
||||
if (setsid() < 0) {
|
||||
fprintf(stderr, "setsid() error %s\n", strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "setsid() error %s\n", strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -909,6 +909,7 @@ unsigned long qtime;
|
||||
&tls_log_info.li_enabled_logs)));
|
||||
dcb->func.write_ready(dcb);
|
||||
} else {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -916,7 +917,7 @@ unsigned long qtime;
|
||||
"dcb %p, fd %i",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno),
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)),
|
||||
dcb,
|
||||
dcb->fd)));
|
||||
}
|
||||
@ -963,6 +964,7 @@ unsigned long qtime;
|
||||
#if defined(FAKE_CODE)
|
||||
if (eno == 0) {
|
||||
eno = dcb_fake_write_errno[dcb->fd];
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -970,18 +972,19 @@ unsigned long qtime;
|
||||
"%s",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
dcb_fake_write_errno[dcb->fd] = 0;
|
||||
#endif /* FAKE_CODE */
|
||||
if (eno != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLERR due %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
atomic_add(&pollStats.n_error, 1);
|
||||
/** Read session id to thread's local storage */
|
||||
@ -996,7 +999,7 @@ unsigned long qtime;
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -1006,7 +1009,7 @@ unsigned long qtime;
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
@ -1029,7 +1032,7 @@ unsigned long qtime;
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
@ -1039,7 +1042,7 @@ unsigned long qtime;
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
|
@ -82,24 +82,26 @@ static int reported = 0;
|
||||
{
|
||||
if (!reported)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Encrypted password file %s can't be accessed "
|
||||
"(%s). Password encryption is not used.",
|
||||
secret_file,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
reported = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : access for secrets file "
|
||||
"[%s] failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -109,13 +111,14 @@ static int reported = 0;
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed opening secret "
|
||||
"file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
|
||||
}
|
||||
@ -125,13 +128,14 @@ static int reported = 0;
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
close(fd);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : fstat for secret file %s "
|
||||
"failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -140,13 +144,14 @@ static int reported = 0;
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
close(fd);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Secrets file %s has "
|
||||
"incorrect size. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
if (secret_stats.st_mode != (S_IRUSR|S_IFREG))
|
||||
@ -182,6 +187,7 @@ static int reported = 0;
|
||||
errno = 0;
|
||||
close(fd);
|
||||
free(keys);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Read from secrets file "
|
||||
@ -190,7 +196,7 @@ static int reported = 0;
|
||||
len,
|
||||
sizeof(MAXKEYS),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -199,13 +205,14 @@ static int reported = 0;
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
free(keys);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed closing the "
|
||||
"secrets file %s. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
ss_dassert(keys != NULL);
|
||||
@ -240,24 +247,26 @@ if(strlen(path) > PATH_MAX)
|
||||
/* Open for writing | Create | Truncate the file for writing */
|
||||
if ((fd = open(secret_file, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed opening secret "
|
||||
"file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open for writing | Create | Truncate the file for writing */
|
||||
if ((randfd = open("/dev/random", O_RDONLY)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed opening /dev/random. Error %d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
@ -280,13 +289,14 @@ if(strlen(path) > PATH_MAX)
|
||||
/* Write data */
|
||||
if (write(fd, &key, sizeof(key)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed writing into "
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
@ -294,24 +304,26 @@ if(strlen(path) > PATH_MAX)
|
||||
/* close file */
|
||||
if (close(fd) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed closing the "
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
if( chmod(secret_file, S_IRUSR) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to change the permissions of the"
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -282,10 +282,11 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
if(errno != EEXIST)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
@ -300,10 +301,11 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
if(errno != EEXIST)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
|
@ -81,12 +81,13 @@ session_alloc(SERVICE *service, DCB *client_dcb)
|
||||
|
||||
if (session == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to allocate memory for "
|
||||
"session object due error %d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
if (client_dcb->data && !DCB_IS_CLONE(client_dcb))
|
||||
{
|
||||
void *clientdata = client_dcb->data;
|
||||
|
@ -61,7 +61,8 @@ int result;
|
||||
dcb->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
if(dcb->fd < 0){
|
||||
ss_dfprintf(stderr, "\nError on function call: socket() returned %d: %s\n",errno,strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr, "\nError on function call: socket() returned %d: %s\n",errno,strerror_r(errno,errbuf,sizeof(errbuf)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -68,22 +68,24 @@ int setnonblocking(int fd) {
|
||||
int fl;
|
||||
|
||||
if ((fl = fcntl(fd, F_GETFL, 0)) == -1) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Can't GET fcntl for %i, errno = %d, %s.",
|
||||
fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, fl | O_NONBLOCK) == -1) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Can't SET fcntl for %i, errno = %d, %s",
|
||||
fd,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -277,12 +277,13 @@ char *remote, *userName;
|
||||
(char *)malloc(strlen(my_instance->filebase) + 20))
|
||||
== NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for qla filter "
|
||||
"file name failed due to %d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(my_session);
|
||||
return NULL;
|
||||
}
|
||||
@ -315,12 +316,13 @@ char *remote, *userName;
|
||||
|
||||
if (my_session->fp == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Opening output file for qla "
|
||||
"fileter failed due to %d, %s",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(my_session->filename);
|
||||
free(my_session);
|
||||
my_session = NULL;
|
||||
@ -329,12 +331,13 @@ char *remote, *userName;
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for qla filter failed due to "
|
||||
"%d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
return my_session;
|
||||
}
|
||||
|
@ -131,7 +131,8 @@ int open_file(char* str, unsigned int write)
|
||||
mode = O_RDONLY;
|
||||
}
|
||||
if((fd = open(str,mode,S_IRWXU|S_IRGRP|S_IXGRP|S_IXOTH)) < 0){
|
||||
printf("Error %d: %s\n",errno,strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
printf("Error %d: %s\n", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
@ -427,7 +427,10 @@ int syseno = 0;
|
||||
sizeof(one));
|
||||
|
||||
if(syseno != 0){
|
||||
skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options. Error %d: %s",
|
||||
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
/* set NONBLOCKING mode */
|
||||
@ -446,10 +449,11 @@ int syseno = 0;
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Failed to start listening http due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -380,12 +380,13 @@ int rc;
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Failed to start listening for maxscale admin connections "
|
||||
"due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -840,7 +840,6 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
if (dcb->state != DCB_STATE_POLLING)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
|
||||
@ -848,12 +847,12 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
{
|
||||
if (error != 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"DCB in state %s got error '%s'.",
|
||||
STRDCBSTATE(dcb->state),
|
||||
buf)));
|
||||
strerror_r(error, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -883,18 +882,17 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&len) == 0)
|
||||
{
|
||||
if (error != 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error '%s' in session that is not ready for routing.",
|
||||
buf)));
|
||||
strerror_r(error, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
gwbuf_free(errbuf);
|
||||
@ -1109,19 +1107,18 @@ gw_backend_hangup(DCB *dcb)
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&len) == 0)
|
||||
{
|
||||
if (error != 0 && ses_state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Hangup in session that is not ready for routing, "
|
||||
"Error reported is '%s'.",
|
||||
buf)));
|
||||
strerror_r(error, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
gwbuf_free(errbuf);
|
||||
|
@ -1355,11 +1355,12 @@ int gw_MySQLListener(
|
||||
|
||||
// UNIX socket create
|
||||
if ((l_so = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Error: can't create UNIX socket due "
|
||||
"error %i, %s.\n\n\t",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
memset(&local_addr, 0, sizeof(local_addr));
|
||||
@ -1376,11 +1377,12 @@ int gw_MySQLListener(
|
||||
}
|
||||
// TCP socket create
|
||||
if ((l_so = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Error: can't create socket due "
|
||||
"error %i, %s.\n\n\t",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1392,13 +1394,15 @@ int gw_MySQLListener(
|
||||
|
||||
// socket options
|
||||
if((syseno = setsockopt(l_so, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one))) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
if(is_tcp)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
if((syseno = setsockopt(l_so, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one))) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
}
|
||||
// set NONBLOCKING mode
|
||||
@ -1413,10 +1417,11 @@ int gw_MySQLListener(
|
||||
}
|
||||
|
||||
if (bind(l_so, (struct sockaddr *) &local_addr, sizeof(local_addr)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Bind failed due error %i, %s.\n",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
fprintf(stderr, "* Can't bind to %s\n\n", config_bind);
|
||||
close(l_so);
|
||||
return 0;
|
||||
@ -1424,21 +1429,23 @@ int gw_MySQLListener(
|
||||
|
||||
/* set permission for all users */
|
||||
if (chmod(config_bind, 0777) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* chmod failed for %s due error %i, %s.\n\n",
|
||||
config_bind,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AF_INET:
|
||||
if (bind(l_so, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Bind failed due error %i, %s.\n",
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
fprintf(stderr, "* Can't bind to %s\n\n", config_bind);
|
||||
close(l_so);
|
||||
return 0;
|
||||
@ -1458,10 +1465,11 @@ int gw_MySQLListener(
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Failed to start listening MySQL due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
close(l_so);
|
||||
return 0;
|
||||
}
|
||||
@ -1554,22 +1562,24 @@ int gw_MySQLAccept(DCB *listener)
|
||||
* Exceeded system's (ENFILE) or processes
|
||||
* (EMFILE) max. number of files limit.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_MySQLAccept] Error %d, %s. ",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error %d, %s. "
|
||||
"Failed to accept new client "
|
||||
"connection.",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
i++;
|
||||
ts1.tv_nsec = 100*i*i*1000000;
|
||||
@ -1586,18 +1596,19 @@ int gw_MySQLAccept(DCB *listener)
|
||||
/**
|
||||
* Other error.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_MySQLAccept] Error %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to accept new client "
|
||||
"connection due to %d, %s.",
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
rc = 1;
|
||||
goto return_rc;
|
||||
} /* if (eno == ..) */
|
||||
@ -1618,15 +1629,16 @@ int gw_MySQLAccept(DCB *listener)
|
||||
#endif /* FAKE_CODE */
|
||||
/* set nonblocking */
|
||||
sendbuf = GW_CLIENT_SO_SNDBUF;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_SNDBUF, &sendbuf, optlen)) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
|
||||
sendbuf = GW_CLIENT_SO_RCVBUF;
|
||||
|
||||
if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_RCVBUF, &sendbuf, optlen)) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
setnonblocking(c_sock);
|
||||
|
||||
|
@ -90,13 +90,14 @@ MySQLProtocol* mysql_protocol_init(
|
||||
if (p == NULL) {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [mysql_init_protocol] MySQL protocol init failed : "
|
||||
"memory allocation due error %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
goto return_p;
|
||||
}
|
||||
p->protocol_state = MYSQL_PROTOCOL_ALLOC;
|
||||
@ -767,6 +768,7 @@ int gw_do_connect_to_backend(
|
||||
so = socket(AF_INET,SOCK_STREAM,0);
|
||||
|
||||
if (so < 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Establishing connection to backend server "
|
||||
@ -775,7 +777,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
goto return_rv;
|
||||
}
|
||||
@ -786,6 +788,7 @@ int gw_do_connect_to_backend(
|
||||
|
||||
if(setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
@ -794,7 +797,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
@ -803,6 +806,7 @@ int gw_do_connect_to_backend(
|
||||
|
||||
if(setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
@ -811,7 +815,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
@ -820,6 +824,7 @@ int gw_do_connect_to_backend(
|
||||
int one = 1;
|
||||
if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
@ -828,7 +833,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
rv = -1;
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
@ -846,6 +851,7 @@ int gw_do_connect_to_backend(
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to connect backend server %s:%d, "
|
||||
@ -853,7 +859,7 @@ int gw_do_connect_to_backend(
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
}
|
||||
@ -878,13 +884,14 @@ close_so:
|
||||
/*< Close newly created socket. */
|
||||
if (close(so) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to "
|
||||
"close socket %d due %d, %s.",
|
||||
so,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
}
|
||||
goto return_rv;
|
||||
}
|
||||
@ -2240,10 +2247,11 @@ char *create_auth_fail_str(
|
||||
|
||||
if (errstr == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation failed due to %s.",
|
||||
strerror(errno))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,8 @@ int syseno = 0;
|
||||
syseno = setsockopt(listener->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one));
|
||||
|
||||
if(syseno != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
return 0;
|
||||
}
|
||||
// set NONBLOCKING mode
|
||||
@ -399,10 +400,11 @@ int syseno = 0;
|
||||
} else {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\n* Failed to start listening telnet due error %d, %s\n\n",
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ errorReply(ROUTER *instance, void *router_session, GWBUF *message, DCB *backend_
|
||||
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance;
|
||||
int error;
|
||||
socklen_t len;
|
||||
char msg[85], *errmsg;
|
||||
char msg[STRERROR_BUFLEN + 1], *errmsg;
|
||||
|
||||
if (action == ERRACT_RESET)
|
||||
{
|
||||
@ -1107,8 +1107,8 @@ char msg[85], *errmsg;
|
||||
len = sizeof(error);
|
||||
if (router->master && getsockopt(router->master->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0 && error != 0)
|
||||
{
|
||||
strerror_r(error, msg, 80);
|
||||
strcat(msg, " ");
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
sprintf(msg, "%s ", strerror_r(error, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
strcpy(msg, "");
|
||||
|
@ -1464,7 +1464,7 @@ static void fail_accept(
|
||||
{
|
||||
int failcount = MIN(atoi(arg2), 100);
|
||||
fail_accept_errno = atoi(arg1);
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
|
||||
switch(fail_accept_errno) {
|
||||
case EAGAIN:
|
||||
@ -1486,7 +1486,7 @@ static void fail_accept(
|
||||
dcb_printf(dcb,
|
||||
"[%d, %s] is not valid errno for accept.\n",
|
||||
fail_accept_errno,
|
||||
strerror(fail_accept_errno));
|
||||
strerror_r(fail_accept_errno, errbuf, sizeof(errbuf)));
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
@ -609,9 +609,11 @@ char** tokenize_string(char* str)
|
||||
char** tmp = realloc(list,sizeof(char*)*(sz*2));
|
||||
if(tmp == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : realloc returned NULL: %s.",strerror(errno))));
|
||||
LOGFILE_ERROR,
|
||||
"Error : realloc returned NULL: %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(list);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -566,9 +566,11 @@ tokenize_string(char* str)
|
||||
char** tmp = realloc(list, sizeof(char*)*(sz * 2));
|
||||
if(tmp == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : realloc returned NULL: %s.", strerror(errno))));
|
||||
"Error : realloc returned NULL: %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
free(list);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -85,9 +85,10 @@ int skygw_rwlock_rdlock(
|
||||
rwlock->srw_rwlock_thr = pthread_self();
|
||||
} else {
|
||||
rwlock->srw_rwlock_thr = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* pthread_rwlock_rdlock : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -101,9 +102,10 @@ int skygw_rwlock_wrlock(
|
||||
rwlock->srw_rwlock_thr = pthread_self();
|
||||
} else {
|
||||
rwlock->srw_rwlock_thr = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* pthread_rwlock_wrlock : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -116,9 +118,10 @@ int skygw_rwlock_unlock(
|
||||
if (err == 0) {
|
||||
rwlock->srw_rwlock_thr = 0;
|
||||
} else {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* pthread_rwlock_unlock : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -132,10 +135,11 @@ int skygw_rwlock_destroy(
|
||||
/** Lock */
|
||||
if ((err = pthread_rwlock_wrlock(rwlock->srw_rwlock)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Error : pthread_rwlock_wrlock failed due to %d, %s.\n",
|
||||
err,
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
goto retblock;
|
||||
}
|
||||
/** Clean the struct */
|
||||
@ -145,10 +149,11 @@ int skygw_rwlock_destroy(
|
||||
/** Destroy */
|
||||
if ((err = pthread_rwlock_destroy(rwlock->srw_rwlock)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Error : pthread_rwlock_destroy failed due to %d,%s\n",
|
||||
err,
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -179,9 +184,10 @@ int skygw_rwlock_init(
|
||||
if (err != 0)
|
||||
{
|
||||
free(rwl);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
ss_dfprintf(stderr,
|
||||
"* Creating pthread_rwlock failed : %s\n",
|
||||
strerror(err));
|
||||
strerror_r(err, errbuf, sizeof(errbuf)));
|
||||
goto return_err;
|
||||
}
|
||||
*rwlock = rwl;
|
||||
@ -1142,11 +1148,12 @@ int skygw_thread_start(
|
||||
ss_dassert(err == 0);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Starting file writer thread failed due error, "
|
||||
"%d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_err;
|
||||
}
|
||||
|
||||
@ -1322,12 +1329,13 @@ simple_mutex_t* simple_mutex_init(
|
||||
err = pthread_mutex_init(&sm->sm_mutex, NULL);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Initializing simple mutex %s failed due error "
|
||||
"%d, %s\n",
|
||||
name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
perror("simple_mutex : ");
|
||||
|
||||
/** Write zeroes if flat, free otherwise. */
|
||||
@ -1361,12 +1369,13 @@ int simple_mutex_done(
|
||||
#if defined(NOT_USED)
|
||||
if (err != 0) {
|
||||
perror("simple_mutex : ");
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Destroying simple mutex %s failed due "
|
||||
"%d, %s\n",
|
||||
sm->sm_name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_err;
|
||||
}
|
||||
#endif
|
||||
@ -1408,12 +1417,13 @@ int simple_mutex_lock(
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking simple mutex %s failed due error, "
|
||||
"%d, %s\n",
|
||||
sm->sm_name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
perror("simple_mutex : ");
|
||||
} else {
|
||||
/**
|
||||
@ -1438,12 +1448,13 @@ int simple_mutex_unlock(
|
||||
err = pthread_mutex_unlock(&sm->sm_mutex);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking simple mutex %s failed due error "
|
||||
"%d, %s\n",
|
||||
sm->sm_name,
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
perror("simple_mutex : ");
|
||||
} else {
|
||||
/**
|
||||
@ -1472,11 +1483,12 @@ skygw_message_t* skygw_message_init(void)
|
||||
err = pthread_mutex_init(&(mes->mes_mutex), NULL);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Initializing pthread mutex failed due error "
|
||||
"%d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
free(mes);
|
||||
mes = NULL;
|
||||
goto return_mes;
|
||||
@ -1484,11 +1496,12 @@ skygw_message_t* skygw_message_init(void)
|
||||
err = pthread_cond_init(&(mes->mes_cond), NULL);
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Initializing pthread cond var failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
pthread_mutex_destroy(&mes->mes_mutex);
|
||||
free(mes);
|
||||
mes = NULL;
|
||||
@ -1514,20 +1527,22 @@ void skygw_message_done(
|
||||
err = pthread_cond_destroy(&(mes->mes_cond));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Destroying cond var failed due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
err = pthread_mutex_destroy(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Destroying pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
free(mes);
|
||||
@ -1543,11 +1558,12 @@ skygw_mes_rc_t skygw_message_send(
|
||||
err = pthread_mutex_lock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread mutex failed, "
|
||||
"due to error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_mes_rc;
|
||||
}
|
||||
mes->mes_sent = true;
|
||||
@ -1559,21 +1575,23 @@ skygw_mes_rc_t skygw_message_send(
|
||||
}
|
||||
else
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Signaling pthread cond var failed, "
|
||||
"due to error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
err = pthread_mutex_unlock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking pthread mutex failed, "
|
||||
"due to error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
|
||||
return_mes_rc:
|
||||
@ -1589,11 +1607,12 @@ void skygw_message_wait(
|
||||
err = pthread_mutex_lock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
|
||||
@ -1601,22 +1620,24 @@ void skygw_message_wait(
|
||||
err = pthread_cond_wait(&(mes->mes_cond), &(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread cond wait failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
}
|
||||
mes->mes_sent = false;
|
||||
err = pthread_mutex_unlock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
}
|
||||
@ -1631,11 +1652,12 @@ void skygw_message_reset(
|
||||
err = pthread_mutex_lock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Locking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_mes_rc;
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
@ -1643,11 +1665,12 @@ void skygw_message_reset(
|
||||
err = pthread_mutex_unlock(&(mes->mes_mutex));
|
||||
|
||||
if (err != 0) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Unlocking pthread mutex failed, "
|
||||
"due error %d, %s\n",
|
||||
err,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto return_mes_rc;
|
||||
}
|
||||
return_mes_rc:
|
||||
@ -1895,11 +1918,12 @@ skygw_file_t* skygw_file_init(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Opening file %s failed due %d, %s.\n",
|
||||
file->sf_fname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
@ -1910,11 +1934,12 @@ skygw_file_t* skygw_file_init(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"\nError : Writing header of log file %s failed due %d, %s.\n",
|
||||
file->sf_fname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
@ -1936,13 +1961,14 @@ skygw_file_t* skygw_file_init(
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"failed to create symlink %s -> "
|
||||
"%s due %d, %s. Exiting.",
|
||||
fname,
|
||||
symlinkname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
@ -1985,11 +2011,12 @@ void skygw_file_close(
|
||||
|
||||
if ((err = fclose(file->sf_file)) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr,
|
||||
"* Closing file %s failed due to %d, %s.\n",
|
||||
file->sf_fname,
|
||||
errno,
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2030,8 +2057,9 @@ char* replace_literal(
|
||||
|
||||
if (search_re == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Regex memory allocation failed : %s\n",
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
newstr = haystack;
|
||||
goto retblock;
|
||||
}
|
||||
@ -2042,8 +2070,9 @@ char* replace_literal(
|
||||
|
||||
if (newstr == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
fprintf(stderr, "Regex memory allocation failed : %s\n",
|
||||
strerror(errno));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
free(search_re);
|
||||
free(newstr);
|
||||
newstr = haystack;
|
||||
|
@ -1,6 +1,13 @@
|
||||
#if !defined(SKYGW_UTILS_H)
|
||||
#define SKYGW_UTILS_H
|
||||
|
||||
/*
|
||||
* We need a common.h file that is included by every component.
|
||||
*/
|
||||
#if !defined(STRERROR_BUFLEN)
|
||||
#define STRERROR_BUFLEN 512
|
||||
#endif
|
||||
|
||||
#define MLIST
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (a<b ? a : b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user