[asterisk-commits] russell: branch
russell/ast_verbose_threadstorage r38410 - /team/russell/ast_...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Jul 28 01:11:24 MST 2006
Author: russell
Date: Fri Jul 28 03:11:24 2006
New Revision: 38410
URL: http://svn.digium.com/view/asterisk?rev=38410&view=rev
Log:
convert ast_inet_ntoa to use the new interface
Modified:
team/russell/ast_verbose_threadstorage/utils.c
Modified: team/russell/ast_verbose_threadstorage/utils.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_verbose_threadstorage/utils.c?rev=38410&r1=38409&r2=38410&view=diff
==============================================================================
--- team/russell/ast_verbose_threadstorage/utils.c (original)
+++ team/russell/ast_verbose_threadstorage/utils.c Fri Jul 28 03:11:24 2006
@@ -65,8 +65,7 @@
static char base64[64];
static char b2a[256];
-static pthread_key_t inet_ntoa_buf_key;
-static pthread_once_t inet_ntoa_buf_once = PTHREAD_ONCE_INIT;
+AST_THREADSTORAGE(inet_ntoa_buf, inet_ntoa_buf_init);
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__)
@@ -489,22 +488,13 @@
*o = '\0';
}
-static void inet_ntoa_buf_key_create(void)
-{
- pthread_key_create(&inet_ntoa_buf_key, FREE);
-}
-
/*! \brief ast_inet_ntoa: Recursive thread safe replacement of inet_ntoa */
const char *ast_inet_ntoa(struct in_addr ia)
{
char *buf;
- pthread_once(&inet_ntoa_buf_once, inet_ntoa_buf_key_create);
- if (!(buf = pthread_getspecific(inet_ntoa_buf_key))) {
- if (!(buf = ast_calloc(1, INET_ADDRSTRLEN)))
- return NULL;
- pthread_setspecific(inet_ntoa_buf_key, buf);
- }
+ if (!(buf = ast_threadstorage_get(&inet_ntoa_buf, INET_ADDRSTRLEN)))
+ return "";
return inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN);
}
More information about the asterisk-commits
mailing list