[asterisk-commits] mmichelson: branch mmichelson/pool_shark r380431 - /team/mmichelson/pool_shar...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 29 16:23:47 CST 2013
Author: mmichelson
Date: Tue Jan 29 16:23:44 2013
New Revision: 380431
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380431
Log:
Use threadlocal storage for the pj_thread_desc passed to pj_thread_register().
This copies quite a bit from res_rtp_asterisk. The net result that I have seen
is that valgrind complains a lot less about conditional jumps and moves depending
on uninitialized data.
Modified:
team/mmichelson/pool_shark/res/res_sip.c
Modified: team/mmichelson/pool_shark/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pool_shark/res/res_sip.c?view=diff&rev=380431&r1=380430&r2=380431
==============================================================================
--- team/mmichelson/pool_shark/res/res_sip.c (original)
+++ team/mmichelson/pool_shark/res/res_sip.c Tue Jan 29 16:23:44 2013
@@ -543,12 +543,23 @@
.on_rx_request = unhandled_on_rx_request,
};
+AST_THREADSTORAGE(pj_thread_storage);
+
static void sip_thread_start(void)
{
- pj_thread_desc desc;
+ pj_thread_desc *desc;
pj_thread_t *thread;
- pj_thread_register("Asterisk Thread", desc, &thread);
+ desc = ast_threadstorage_get(&pj_thread_storage, sizeof(pj_thread_desc));
+ if (!desc) {
+ ast_log(LOG_ERROR, "Could not get thread desc from thread-local storage. Expect awful things to occur\n");
+ return;
+ }
+ pj_bzero(*desc, sizeof(*desc));
+
+ if (pj_thread_register("Asterisk Thread", *desc, &thread) != PJ_SUCCESS) {
+ ast_log(LOG_ERROR, "Couldn't register thread with PJLIB.\n");
+ }
}
static int load_module(void)
More information about the asterisk-commits
mailing list