Fix mxb_strerror
The function should not be an inline function with a static variable. This appears to cause problems on at least Debian Wheezy and is likely to cause odd behavior on other platforms. Also renamed the file to <maxbase/string.h> to better mirror how the <string.h> file behaves.
This commit is contained in:
parent
3b8f01e136
commit
be4f9125f0
20
maxutils/maxbase/include/maxbase/string.h
Normal file
20
maxutils/maxbase/include/maxbase/string.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
/*
|
||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
||||
*
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
|
||||
*
|
||||
* Change Date: 2022-01-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include <maxbase/cdefs.h>
|
||||
|
||||
/**
|
||||
* Thread-safe strerror
|
||||
*/
|
||||
const char* mxb_strerror(int error);
|
@ -3,6 +3,7 @@ add_library(maxbase STATIC
|
||||
eventcount.cc
|
||||
logger.cc
|
||||
stopwatch.cc
|
||||
string.cc
|
||||
stacktrace.cc
|
||||
)
|
||||
set_target_properties(maxbase PROPERTIES VERSION "1.0.0" LINK_FLAGS -Wl,-z,defs)
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
|
||||
#include <maxbase/error.h>
|
||||
#include <maxbase/string.h>
|
||||
|
||||
// TODO: move <maxscale/debug.h> into maxbase
|
||||
#define ss_dassert(a)
|
||||
|
@ -1,4 +1,3 @@
|
||||
#pragma once
|
||||
/*
|
||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
||||
*
|
||||
@ -12,14 +11,19 @@
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include <maxbase/cdefs.h>
|
||||
#include <maxbase/string.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
inline const char* mxb_strerror(int error)
|
||||
namespace
|
||||
{
|
||||
|
||||
thread_local char errbuf[512]; // Enough for all errors
|
||||
|
||||
}
|
||||
|
||||
const char* mxb_strerror(int error)
|
||||
{
|
||||
// Enough for all errors
|
||||
static thread_local char errbuf[512];
|
||||
#ifdef HAVE_GLIBC
|
||||
return strerror_r(error, errbuf, sizeof(errbuf));
|
||||
#else
|
@ -22,7 +22,7 @@
|
||||
#include <mutex>
|
||||
|
||||
#include <maxbase/atomic.h>
|
||||
#include <maxbase/error.h>
|
||||
#include <maxbase/string.h>
|
||||
#include <maxbase/logger.hh>
|
||||
|
||||
#include <maxscale/alloc.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user