rDSN
rDSN copied to clipboard
strerror is not thread safe.
Here is a ref implementation in file_utils.cpp:
namespace dsn{
namespace utils {
char *get_error_str(int errnum)
{
size_t sz = ARRAYSIZE(tls_path_buffer);
auto ret =
# if defined(_WIN32)
::strerror_s(tls_path_buffer, sz, errnum)
# else
::strerror_r(errnum, str_buffer, sz)
# endif
;
if (ret != 0)
{
snprintf_p(tls_path_buffer, sz, "Unknown system error.");
}
return tls_path_buffer;
}
}
}
@imzhenyu, the code piece here is fine to fix the "strerror" bug, but I can't find it in our project. So is it OK if I add this to our project and change all the function calls to strerror?
That will definitely help~