diff options
Diffstat (limited to 'channels/chan_vofr.c')
-rwxr-xr-x | channels/chan_vofr.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/channels/chan_vofr.c b/channels/chan_vofr.c index 4cbc71f2b..37d8a1f52 100755 --- a/channels/chan_vofr.c +++ b/channels/chan_vofr.c @@ -53,14 +53,14 @@ static char context[AST_MAX_EXTENSION] = "default"; static char language[MAX_LANGUAGE] = ""; static int usecnt =0; -static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; +static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; /* Protect the interface list (of vofr_pvt's) */ -static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER; +static ast_mutex_t iflock = AST_MUTEX_INITIALIZER; /* Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical. */ -static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER; +static ast_mutex_t monlock = AST_MUTEX_INITIALIZER; /* This is the thread for the monitor which checks for input on the channels which are not currently in use. */ @@ -457,11 +457,11 @@ static int vofr_hangup(struct ast_channel *ast) ast->state = AST_STATE_DOWN; ((struct vofr_pvt *)(ast->pvt->pvt))->owner = NULL; ((struct vofr_pvt *)(ast->pvt->pvt))->ringgothangup = 0; - ast_pthread_mutex_lock(&usecnt_lock); + ast_mutex_lock(&usecnt_lock); usecnt--; if (usecnt < 0) ast_log(LOG_WARNING, "Usecnt < 0???\n"); - ast_pthread_mutex_unlock(&usecnt_lock); + ast_mutex_unlock(&usecnt_lock); ast_update_use_count(); if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name); @@ -826,9 +826,9 @@ static struct ast_channel *vofr_new(struct vofr_pvt *i, int state) if (strlen(i->language)) strncpy(tmp->language, i->language, sizeof(tmp->language)-1); i->owner = tmp; - ast_pthread_mutex_lock(&usecnt_lock); + ast_mutex_lock(&usecnt_lock); usecnt++; - ast_pthread_mutex_unlock(&usecnt_lock); + ast_mutex_unlock(&usecnt_lock); ast_update_use_count(); strncpy(tmp->context, i->context, sizeof(tmp->context)-1); if (state != AST_STATE_DOWN) { @@ -916,14 +916,14 @@ static void *do_monitor(void *data) for(;;) { /* Don't let anybody kill us right away. Nobody should lock the interface list and wait for the monitor list, but the other way around is okay. */ - if (ast_pthread_mutex_lock(&monlock)) { + if (ast_mutex_lock(&monlock)) { ast_log(LOG_ERROR, "Unable to grab monitor lock\n"); return NULL; } /* Lock the interface list */ - if (ast_pthread_mutex_lock(&iflock)) { + if (ast_mutex_lock(&iflock)) { ast_log(LOG_ERROR, "Unable to grab interface lock\n"); - ast_pthread_mutex_unlock(&monlock); + ast_mutex_unlock(&monlock); return NULL; } /* Build the stuff we're going to select on, that is the socket of every @@ -947,10 +947,10 @@ static void *do_monitor(void *data) i = i->next; } /* Okay, now that we know what to do, release the interface lock */ - ast_pthread_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); /* And from now on, we're okay to be killed, so release the monitor lock as well */ - ast_pthread_mutex_unlock(&monlock); + ast_mutex_unlock(&monlock); pthread_testcancel(); /* Wait indefinitely for something to happen */ res = ast_select(n + 1, &rfds, NULL, NULL, NULL); @@ -963,7 +963,7 @@ static void *do_monitor(void *data) } /* Alright, lock the interface list again, and let's look and see what has happened */ - if (ast_pthread_mutex_lock(&iflock)) { + if (ast_mutex_lock(&iflock)) { ast_log(LOG_WARNING, "Unable to lock the interface list\n"); continue; } @@ -987,7 +987,7 @@ static void *do_monitor(void *data) } i=i->next; } - ast_pthread_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); } /* Never reached */ return NULL; @@ -999,12 +999,12 @@ static int restart_monitor(void) /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == -2) return 0; - if (ast_pthread_mutex_lock(&monlock)) { + if (ast_mutex_lock(&monlock)) { ast_log(LOG_WARNING, "Unable to lock monitor\n"); return -1; } if (monitor_thread == pthread_self()) { - ast_pthread_mutex_unlock(&monlock); + ast_mutex_unlock(&monlock); ast_log(LOG_WARNING, "Cannot kill myself\n"); return -1; } @@ -1014,12 +1014,12 @@ static int restart_monitor(void) } else { /* Start a new monitor */ if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) { - ast_pthread_mutex_unlock(&monlock); + ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; } } - ast_pthread_mutex_unlock(&monlock); + ast_mutex_unlock(&monlock); return 0; } @@ -1119,7 +1119,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data) return NULL; } /* Search for an unowned channel */ - if (ast_pthread_mutex_lock(&iflock)) { + if (ast_mutex_lock(&iflock)) { ast_log(LOG_ERROR, "Unable to lock interface list???\n"); return NULL; } @@ -1131,7 +1131,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data) } p = p->next; } - ast_pthread_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); restart_monitor(); return tmp; } @@ -1148,7 +1148,7 @@ int load_module() ast_log(LOG_ERROR, "Unable to load config %s\n", config); return -1; } - if (ast_pthread_mutex_lock(&iflock)) { + if (ast_mutex_lock(&iflock)) { /* It's a little silly to lock it, but we mind as well just to be sure */ ast_log(LOG_ERROR, "Unable to lock interface list???\n"); return -1; @@ -1165,7 +1165,7 @@ int load_module() } else { ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value); ast_destroy(cfg); - ast_pthread_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); unload_module(); return -1; } @@ -1176,7 +1176,7 @@ int load_module() } v = v->next; } - ast_pthread_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); /* Make sure we can register our AdtranVoFR channel type */ if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) { ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); @@ -1195,7 +1195,7 @@ int unload_module() struct vofr_pvt *p, *pl; /* First, take us out of the channel loop */ ast_channel_unregister(type); - if (!ast_pthread_mutex_lock(&iflock)) { + if (!ast_mutex_lock(&iflock)) { /* Hangup all interfaces if they have an owner */ p = iflist; while(p) { @@ -1204,25 +1204,25 @@ int unload_module() p = p->next; } iflist = NULL; - ast_pthread_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); } else { ast_log(LOG_WARNING, "Unable to lock the monitor\n"); return -1; } - if (!ast_pthread_mutex_lock(&monlock)) { + if (!ast_mutex_lock(&monlock)) { if (monitor_thread) { pthread_cancel(monitor_thread); pthread_kill(monitor_thread, SIGURG); pthread_join(monitor_thread, NULL); } monitor_thread = -2; - ast_pthread_mutex_unlock(&monlock); + ast_mutex_unlock(&monlock); } else { ast_log(LOG_WARNING, "Unable to lock the monitor\n"); return -1; } - if (!ast_pthread_mutex_lock(&iflock)) { + if (!ast_mutex_lock(&iflock)) { /* Destroy all the interfaces and free their memory */ p = iflist; while(p) { @@ -1235,7 +1235,7 @@ int unload_module() free(pl); } iflist = NULL; - ast_pthread_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); } else { ast_log(LOG_WARNING, "Unable to lock the monitor\n"); return -1; @@ -1247,9 +1247,9 @@ int unload_module() int usecount() { int res; - ast_pthread_mutex_lock(&usecnt_lock); + ast_mutex_lock(&usecnt_lock); res = usecnt; - ast_pthread_mutex_unlock(&usecnt_lock); + ast_mutex_unlock(&usecnt_lock); return res; } |