aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_vpb.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-17 16:42:21 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-17 16:42:21 +0000
commit2f4660a236080dac4740887e276208c4a12c743c (patch)
tree69bea73175a4ad33bd963b1f0c97c206b89a33ab /channels/chan_vpb.c
parent34fbed82538f271aae21f2dfd53f27d2bc824f18 (diff)
more module loader related fixes
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20963 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_vpb.c')
-rw-r--r--channels/chan_vpb.c132
1 files changed, 66 insertions, 66 deletions
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;