From 2f4660a236080dac4740887e276208c4a12c743c Mon Sep 17 00:00:00 2001 From: kpfleming Date: Mon, 17 Apr 2006 16:42:21 +0000 Subject: more module loader related fixes git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20963 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_vpb.c | 132 ++++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'channels/chan_vpb.c') diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c index e408718a7..af55eda57 100644 --- a/channels/chan_vpb.c +++ b/channels/chan_vpb.c @@ -2773,6 +2773,72 @@ static float parse_gain_value(char *gain_type, char *value) return gain; } + +int unload_module() +{ + struct vpb_pvt *p; + /* First, take us out of the channel loop */ + if (use_ast_ind == 1){ + ast_channel_unregister(&vpb_tech_indicate); + } + else { + ast_channel_unregister(&vpb_tech); + } + + ast_mutex_lock(&iflock); { + /* Hangup all interfaces if they have an owner */ + p = iflist; + while(p) { + if (p->owner) + ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD); + p = p->next; + } + iflist = NULL; + } ast_mutex_unlock(&iflock); + + ast_mutex_lock(&monlock); { + if (mthreadactive > -1) { + pthread_cancel(monitor_thread); + pthread_join(monitor_thread, NULL); + } + mthreadactive = -2; + } ast_mutex_unlock(&monlock); + + ast_mutex_lock(&iflock); { + /* Destroy all the interfaces and free their memory */ + + while(iflist) { + p = iflist; + ast_mutex_destroy(&p->lock); + pthread_cancel(p->readthread); + ast_mutex_destroy(&p->owner_lock); + ast_mutex_destroy(&p->record_lock); + ast_mutex_destroy(&p->play_lock); + ast_mutex_destroy(&p->play_dtmf_lock); + p->readthread = 0; + + vpb_close(p->handle); + + iflist = iflist->next; + + free(p); + } + iflist = NULL; + } ast_mutex_unlock(&iflock); + + ast_mutex_lock(&bridge_lock); { + memset(bridges, 0, sizeof bridges); + } ast_mutex_unlock(&bridge_lock); + ast_mutex_destroy(&bridge_lock); + for(int i = 0; i < max_bridges; i++ ) { + ast_mutex_destroy(&bridges[i].lock); + ast_cond_destroy(&bridges[i].cond); + } + free(bridges); + + return 0; +} + int load_module() { struct ast_config *cfg; @@ -2969,72 +3035,6 @@ int load_module() return error; } - -int unload_module() -{ - struct vpb_pvt *p; - /* First, take us out of the channel loop */ - if (use_ast_ind == 1){ - ast_channel_unregister(&vpb_tech_indicate); - } - else { - ast_channel_unregister(&vpb_tech); - } - - ast_mutex_lock(&iflock); { - /* Hangup all interfaces if they have an owner */ - p = iflist; - while(p) { - if (p->owner) - ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD); - p = p->next; - } - iflist = NULL; - } ast_mutex_unlock(&iflock); - - ast_mutex_lock(&monlock); { - if (mthreadactive > -1) { - pthread_cancel(monitor_thread); - pthread_join(monitor_thread, NULL); - } - mthreadactive = -2; - } ast_mutex_unlock(&monlock); - - ast_mutex_lock(&iflock); { - /* Destroy all the interfaces and free their memory */ - - while(iflist) { - p = iflist; - ast_mutex_destroy(&p->lock); - pthread_cancel(p->readthread); - ast_mutex_destroy(&p->owner_lock); - ast_mutex_destroy(&p->record_lock); - ast_mutex_destroy(&p->play_lock); - ast_mutex_destroy(&p->play_dtmf_lock); - p->readthread = 0; - - vpb_close(p->handle); - - iflist = iflist->next; - - free(p); - } - iflist = NULL; - } ast_mutex_unlock(&iflock); - - ast_mutex_lock(&bridge_lock); { - memset(bridges, 0, sizeof bridges); - } ast_mutex_unlock(&bridge_lock); - ast_mutex_destroy(&bridge_lock); - for(int i = 0; i < max_bridges; i++ ) { - ast_mutex_destroy(&bridges[i].lock); - ast_cond_destroy(&bridges[i].cond); - } - free(bridges); - - return 0; -} - int usecount() { return usecnt; -- cgit v1.2.3