From: Brian Aker Date: Fri, 17 Jun 2011 21:18:54 +0000 (-0700) Subject: Make sure we use the correct strerror() in case someone is using threads. X-Git-Tag: 0.51~4^2~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=e7855e43bbc4dd0a5e8fcbfd4888181001dcd1ec;p=awesomized%2Flibmemcached Make sure we use the correct strerror() in case someone is using threads. --- diff --git a/libmemcached/error.cc b/libmemcached/error.cc index 49375097..5cfb4be2 100644 --- a/libmemcached/error.cc +++ b/libmemcached/error.cc @@ -99,18 +99,35 @@ static void _set(memcached_st& memc, memcached_string_t *str, memcached_return_t error->rc= rc; error->local_errno= local_errno; + const char *errmsg_ptr; + char errmsg[MAX_ERROR_LENGTH]; + errmsg[0]= 0; + errmsg_ptr= errmsg; + + if (local_errno) + { +#ifdef STRERROR_R_CHAR_P + errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg)); +#else + strerror_r(local_errno, errmsg, sizeof(errmsg)); + errmsg_ptr= errmsg; +#endif + } + + if (str and str->size and local_errno) { error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s(%s), %.*s -> %s", memcached_strerror(&memc, rc), - strerror(local_errno), + errmsg_ptr, memcached_string_printf(*str), at); } else if (local_errno) { error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s(%s) -> %s", memcached_strerror(&memc, rc), - strerror(local_errno), at); + errmsg_ptr, + at); } else if (str and str->size) {