[asterisk-commits] qwell: trunk r40600 - /trunk/channels/chan_skinny.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Aug 19 21:39:57 MST 2006


Author: qwell
Date: Sat Aug 19 23:39:57 2006
New Revision: 40600

URL: http://svn.digium.com/view/asterisk?rev=40600&view=rev
Log:
Converted device2str and control2str to use thread local storage.

Thanks Russell.

Modified:
    trunk/channels/chan_skinny.c

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?rev=40600&r1=40599&r2=40600&view=diff
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Sat Aug 19 23:39:57 2006
@@ -72,6 +72,7 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/astobj.h"
 #include "asterisk/abstract_jb.h"
+#include "asterisk/threadstorage.h"
 
 /*************************************
  * Skinny/Asterisk Protocol Settings *
@@ -123,6 +124,12 @@
 	.impl = ""
 };
 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 char *device2str(int type)
 {
-	static char tmp[15];
+	static char *tmp;
 
 	switch (type) {
 	case SKINNY_DEVICE_NONE:
@@ -1758,7 +1765,9 @@
 	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 char *control2str(int ind) {
-	static char tmp[100];
+	static char *tmp;
 
 	switch (ind) {
 	case AST_CONTROL_HANGUP:
@@ -2509,7 +2518,9 @@
 	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;
 	}
 }



More information about the asterisk-commits mailing list