[asterisk-commits] mmichelson: branch group/pimp_my_sip r378821 - /team/group/pimp_my_sip/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 9 15:32:01 CST 2013
Author: mmichelson
Date: Wed Jan 9 15:31:58 2013
New Revision: 378821
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378821
Log:
Start up a monitor thread when res_sip loads.
This is lifted almost directly from Asterisk SCF. The thread
simply runs a forever loop where it checks the pjsip_endpoint
every ten milliseconds for new events to handle.
This will surely need revisiting later since, well, there's no
way to actually stop the thread :)
Modified:
team/group/pimp_my_sip/res/res_sip.c
Modified: team/group/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.c?view=diff&rev=378821&r1=378820&r2=378821
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.c (original)
+++ team/group/pimp_my_sip/res/res_sip.c Wed Jan 9 15:31:58 2013
@@ -239,9 +239,45 @@
return 0;
}
+pj_caching_pool caching_pool;
+pj_pool_t *memory_pool;
+pj_thread_t *monitor_thread;
+
+static void *monitor_thread_exec(void *endpt)
+{
+ for (;;) {
+ const pj_time_val delay = {0, 10};
+ pjsip_endpt_handle_events(ast_pjsip_endpoint, &delay);
+ }
+ return NULL;
+}
+
static int load_module(void)
{
- /* XXX stub */
+ /* The third parameter is just copied from
+ * example code from PJLIB. This can be adjusted
+ * if necessary.
+ */
+ pj_status_t status;
+ pj_caching_pool_init(&caching_pool, NULL, 1024 * 1024);
+ pjsip_endpt_create(&caching_pool.factory, "SIP", &ast_pjsip_endpoint);
+ memory_pool = pj_pool_create(&caching_pool.factory, "SIP", 1024, 1024, NULL);
+ if (!memory_pool) {
+ ast_log(LOG_ERROR, "Failed to create memory pool for SIP. Aborting load\n");
+ pjsip_endpt_destroy(ast_pjsip_endpoint);
+ pj_caching_pool_destroy(&caching_pool);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
+ status = pj_thread_create(memory_pool, "SIP", (pj_thread_proc *) &monitor_thread_exec,
+ NULL, PJ_THREAD_DEFAULT_STACK_SIZE * 2, 0, &monitor_thread);
+ if (status != PJ_SUCCESS) {
+ ast_log(LOG_ERROR, "Failed to start SIP monitor thread. Aborting load\n");
+ pj_pool_release(memory_pool);
+ pjsip_endpt_destroy(ast_pjsip_endpoint);
+ pj_caching_pool_destroy(&caching_pool);
+ return AST_MODULE_LOAD_DECLINE;
+ }
return AST_MODULE_LOAD_SUCCESS;
}
More information about the asterisk-commits
mailing list