diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2009-09-26 13:09:00 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2009-09-26 23:13:16 +0200 |
commit | 8c2ece4514e602a5c66f98eb2b12556b22b48d61 (patch) | |
tree | 4eff5d7c21d689ecee6b37e5b6ca9b56e9c95662 | |
parent | d75a7671a4665766c2f7c958073a7f70ee6f260a (diff) |
Add skeleton for the OpenBSC integration / thread
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r-- | chan_openbsc.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/chan_openbsc.c b/chan_openbsc.c index 52cf41d..343d0a0 100644 --- a/chan_openbsc.c +++ b/chan_openbsc.c @@ -14,12 +14,56 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: $") +#include <pthread.h> +#include <unistd.h> + #include "asterisk/channel.h" #include "asterisk/logger.h" #include "asterisk/module.h" /* ------------------------------------------------------------------------ */ +/* OpenBSC */ +/* ---------------------------------------------------------------------{{{ */ + + +/* Main thread */ +static int g_done; +static pthread_t g_main_tid; + +static void * +openbsc_main(void *arg) +{ + ast_log(LOG_DEBUG, "OpenBSC channel main thread started\n"); + + while (!g_done) { + sleep(1.0); + ast_log(LOG_DEBUG, "OpenBSC alive\n"); + } + + ast_log(LOG_DEBUG, "OpenBSC channel main thread exiting\n"); + + return NULL; +} + +static int +openbsc_start(void) +{ + g_done = 0; + return pthread_create(&g_main_tid, NULL, openbsc_main, NULL); +} + +static void +openbsc_stop(void) +{ + g_done = 1; + pthread_join(g_main_tid, NULL); +} + +/* }}} */ + + +/* ------------------------------------------------------------------------ */ /* Channel driver */ /* ---------------------------------------------------------------------{{{ */ @@ -249,6 +293,12 @@ load_module(void) return AST_MODULE_LOAD_FAILURE; } + if (openbsc_start()) { + ast_channel_unregister(&openbsc_tech); + ast_log(LOG_ERROR, "Unable to start OpenBSC main thread\n"); + return AST_MODULE_LOAD_FAILURE; + } + ast_log(LOG_NOTICE, "OpenBSC channel driver loaded\n"); return AST_MODULE_LOAD_SUCCESS; @@ -260,6 +310,8 @@ unload_module(void) { ast_log(LOG_NOTICE, "OpenBSC channel driver unloading.\n"); + openbsc_stop(); + ast_channel_unregister(&openbsc_tech); return 0; |