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

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