Add mxs_strerror

Thread-safe version of strerror; thread local buffer used for storing
the message. The performance penalty of a thread local buffer is not
likely to be significant, since this is only called in an error
situation that anyway is likely to interrupt the normal processing.
This commit is contained in:
Johan Wikman
2017-02-13 16:13:26 +02:00
parent 9a03ba4566
commit 20da2c7db8
2 changed files with 25 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include <errno.h>
#include <syslog.h>
#include <maxscale/atomic.h>
#include <maxscale/platform.h>
#include <maxscale/hashtable.h>
#include <maxscale/spinlock.h>
@ -3045,3 +3046,10 @@ int mxs_log_message(int priority,
return err;
}
const char* mxs_strerror(int error)
{
static thread_local char errbuf[MXS_STRERROR_BUFLEN];
return strerror_r(error, errbuf, sizeof(errbuf));
}