aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-20 04:39:57 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-20 04:39:57 +0000
commit020e98bef4b5d2368966f1fe217034b998931e09 (patch)
tree5ff1b625262a48d3df68d1751f8cf7b82f3a2e9f /channels
parentfa59ea28ae618e4f1b60488ecd4b0add3532a185 (diff)
Converted device2str and control2str to use thread local storage.
Thanks Russell. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40600 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_skinny.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 8acf32984..7c3d59e76 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -72,6 +72,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/stringfields.h"
#include "asterisk/astobj.h"
#include "asterisk/abstract_jb.h"
+#include "asterisk/threadstorage.h"
/*************************************
* Skinny/Asterisk Protocol Settings *
@@ -124,6 +125,12 @@ static struct ast_jb_conf default_jbconf =
};
static struct ast_jb_conf global_jbconf;
+AST_THREADSTORAGE(device2str_threadbuf, device2str_threadbuf_init);
+#define DEVICE2STR_BUFSIZE 15
+
+AST_THREADSTORAGE(control2str_threadbuf, control2str_threadbuf_init);
+#define CONTROL2STR_BUFSIZE 100
+
/*********************
* Protocol Messages *
*********************/
@@ -1698,7 +1705,7 @@ static int skinny_reset_device(int fd, int argc, char *argv[])
static char *device2str(int type)
{
- static char tmp[15];
+ static char *tmp;
switch (type) {
case SKINNY_DEVICE_NONE:
@@ -1758,7 +1765,9 @@ static char *device2str(int type)
case SKINNY_DEVICE_UNKNOWN:
return "Unknown";
default:
- snprintf(tmp, sizeof(tmp), "UNKNOWN-%d", type);
+ if (!(tmp = ast_threadstorage_get(&device2str_threadbuf, DEVICE2STR_BUFSIZE)))
+ return "Unknown";
+ snprintf(tmp, DEVICE2STR_BUFSIZE, "UNKNOWN-%d", type);
return tmp;
}
}
@@ -2469,7 +2478,7 @@ static int skinny_senddigit(struct ast_channel *ast, char digit)
}
static char *control2str(int ind) {
- static char tmp[100];
+ static char *tmp;
switch (ind) {
case AST_CONTROL_HANGUP:
@@ -2509,7 +2518,9 @@ static char *control2str(int ind) {
case -1:
return "Stop tone";
default:
- snprintf(tmp, sizeof(tmp), "UNKNOWN-%d", ind);
+ if (!(tmp = ast_threadstorage_get(&control2str_threadbuf, CONTROL2STR_BUFSIZE)))
+ return "Unknown";
+ snprintf(tmp, CONTROL2STR_BUFSIZE, "UNKNOWN-%d", ind);
return tmp;
}
}