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:
Johan Wikman
2015-09-05 15:32:32 +03:00
parent a9fd7926ac
commit 160bbb70ee
31 changed files with 314 additions and 167 deletions

View File

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

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