Develop merge

Develop merge
This commit is contained in:
MassimilianoPinto
2015-09-07 11:13:49 +02:00
30 changed files with 337 additions and 185 deletions

View File

@ -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);

View File

@ -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);
@ -1426,12 +1427,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);
@ -2481,4 +2483,4 @@ bool check_service_permissions(SERVICE* service)
mysql_close(mysql);
free(dpasswd);
return rval;
}
}

View File

@ -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.");

View File

@ -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)

View File

@ -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;
}

View File

@ -323,9 +323,9 @@ static void sigusr1_handler (int i)
static void sigterm_handler (int i) {
extern void shutdown_server();
LOGIF(LE, (skygw_log_write_flush(
skygw_log_write_flush(
LOGFILE_ERROR,
"MaxScale received signal SIGTERM. Exiting.")));
"MaxScale received signal SIGTERM. Exiting.");
skygw_log_sync_all();
shutdown_server();
}
@ -335,9 +335,9 @@ sigint_handler (int i)
{
extern void shutdown_server();
LOGIF(LE, (skygw_log_write_flush(
skygw_log_write_flush(
LOGFILE_ERROR,
"MaxScale received signal SIGINT. Shutting down.")));
"MaxScale received signal SIGINT. Shutting down.");
skygw_log_sync_all();
shutdown_server();
fprintf(stderr, "\n\nShutting down MaxScale\n\n");
@ -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
{
@ -394,9 +393,9 @@ sigfatal_handler (int i)
GATEWAY_CONF* cnf = config_get_global_options();
fprintf(stderr, "\n\nMaxScale "MAXSCALE_VERSION" received fatal signal %d\n", i);
LOGIF(LE, (skygw_log_write_flush(
skygw_log_write_flush(
LOGFILE_ERROR,
"Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i)));
"Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i);
skygw_log_write_flush(LE,"Commit ID: %s System name: %s "
"Release string: %s Embedded library version: %s",
@ -409,9 +408,9 @@ sigfatal_handler (int i)
if (symbols) {
for( n = 0; n < count; n++ ) {
LOGIF(LE, (skygw_log_write_flush(
skygw_log_write_flush(
LOGFILE_ERROR,
" %s\n", symbols[n])));
" %s\n", symbols[n]);
}
free(symbols);
} else {
@ -456,12 +455,13 @@ static int signal_set (int sig, void (*handler)(int)) {
{
int eno = errno;
errno = 0;
LOGIF(LE, (skygw_log_write_flush(
char errbuf[STRERROR_BUFLEN];
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;
LOGIF(LE, (skygw_log_write(
char errbuf[STRERROR_BUFLEN];
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) {
LOGIF(LE, (skygw_log_write_flush(
char errbuf[STRERROR_BUFLEN];
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,16 +823,16 @@ 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(
skygw_log_write_flush(
LOGFILE_ERROR,
"Warning : Failed to read the configuration file %s due "
"to %d, %s.",
absolute_pathname,
eno,
strerror(eno))));
LOGIF(LE,(skygw_log_sync_all()));
strerror_r(eno, errbuf, sizeof(errbuf)));
skygw_log_sync_all();
succp = false;
}
return succp;
@ -844,6 +847,7 @@ static bool file_is_writable(
{
int eno = errno;
errno = 0;
char errbuf[STRERROR_BUFLEN];
if (!daemon_mode)
{
@ -852,15 +856,15 @@ 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(
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : unable to open file %s for write due "
"to %d, %s.",
absolute_pathname,
eno,
strerror(eno))));
strerror_r(eno, errbuf, sizeof(errbuf)));
succp = false;
}
return succp;
@ -907,21 +911,22 @@ 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));
LOGIF(LE, (skygw_log_write_flush(
strerror_r(eno, errbuf, sizeof(errbuf)));
skygw_log_write_flush(
LOGFILE_ERROR,
"Warning : Failed to read the "
"directory %s, due "
"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);
LOGIF(LE, (skygw_log_write_flush(
char errbuf[STRERROR_BUFLEN];
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;
}
}
@ -1818,7 +1828,7 @@ int main(int argc, char **argv)
}
}
}
LOGIF(LE, (skygw_log_write_flush(
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : mysql_library_init failed. It is a "
"mandatory component, required by router services and "
@ -1826,7 +1836,7 @@ int main(int argc, char **argv)
mysql_errno(NULL),
mysql_error(NULL),
__FILE__,
__LINE__)));
__LINE__);
rc = MAXSCALE_NOLIBRARY;
goto return_main;
}
@ -1837,11 +1847,11 @@ int main(int argc, char **argv)
char* fprerr = "Failed to load MaxScale configuration "
"file. Exiting. See the error log for details.";
print_log_n_stderr(false, !daemon_mode, fprerr, fprerr, 0);
LOGIF(LE, (skygw_log_write_flush(
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to load MaxScale configuration file %s. "
"Exiting.",
cnf_file_path)));
cnf_file_path);
rc = MAXSCALE_BADCONFIG;
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;
}
}

View File

@ -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);
}
}

View File

@ -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)

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 ;
}
}

View File

@ -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;
}

View File

@ -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;
}