aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-13 15:25:16 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-13 15:25:16 +0000
commitdbc9edcaac6ec1d2059f4c5bcd27cca6c266f5bf (patch)
tree3f2cc11c392b1496cf6518e8b6eb99e8b04417a1 /channels
parent231b9aad4020331a8c68d1a2826ee1ef930ec57b (diff)
Totally revamp thread debugging to support locating and removing deadlocks
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1310 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_agent.c192
-rwxr-xr-xchannels/chan_alsa.c14
-rwxr-xr-xchannels/chan_iax.c260
-rwxr-xr-xchannels/chan_iax2.c308
-rwxr-xr-xchannels/chan_local.c98
-rwxr-xr-xchannels/chan_mgcp.c96
-rwxr-xr-xchannels/chan_modem.c64
-rwxr-xr-xchannels/chan_modem_aopen.c14
-rwxr-xr-xchannels/chan_modem_bestdata.c14
-rwxr-xr-xchannels/chan_modem_i4l.c14
-rwxr-xr-xchannels/chan_nbs.c10
-rwxr-xr-xchannels/chan_oss.c14
-rwxr-xr-xchannels/chan_phone.c78
-rwxr-xr-xchannels/chan_sip.c288
-rwxr-xr-xchannels/chan_vofr.c62
-rwxr-xr-xchannels/chan_vpb.c104
-rwxr-xr-xchannels/chan_zap.c214
-rwxr-xr-xchannels/chan_zap_old.c166
18 files changed, 1007 insertions, 1003 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 53dd4e7e9..74155d0a8 100755
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -81,13 +81,13 @@ static int wrapuptime;
static int ackcall;
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 sip_pvt's) */
-static pthread_mutex_t agentlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t agentlock = AST_MUTEX_INITIALIZER;
static struct agent_pvt {
- pthread_mutex_t lock; /* Channel private lock */
+ ast_mutex_t lock; /* Channel private lock */
int dead; /* Poised for destruction? */
int pending; /* Not a real agent -- just pending a match */
int abouttograb; /* About to grab */
@@ -102,7 +102,7 @@ static struct agent_pvt {
char agent[AST_MAX_AGENT]; /* Agent ID */
char password[AST_MAX_AGENT]; /* Password for Agent login */
char name[AST_MAX_AGENT];
- pthread_mutex_t app_lock; /* Synchronization between owning applications */
+ ast_mutex_t app_lock; /* Synchronization between owning applications */
volatile pthread_t owning_app; /* Owning application thread id */
volatile int app_sleep_cond; /* Sleep condition for the login app */
struct ast_channel *owner; /* Agent */
@@ -168,8 +168,8 @@ static struct agent_pvt *add_agent(char *agent, int pending)
if (p) {
memset(p, 0, sizeof(struct agent_pvt));
strncpy(p->agent, tmp, sizeof(p->agent) -1);
- ast_pthread_mutex_init( &p->lock );
- ast_pthread_mutex_init( &p->app_lock );
+ ast_mutex_init( &p->lock );
+ ast_mutex_init( &p->app_lock );
p->owning_app = -1;
p->app_sleep_cond = 1;
p->group = group;
@@ -204,7 +204,7 @@ static int agent_cleanup(struct agent_pvt *p)
chan->pvt->pvt = NULL;
p->app_sleep_cond = 1;
/* Release ownership of the agent to other threads (presumably running the login app). */
- ast_pthread_mutex_unlock(&p->app_lock);
+ ast_mutex_unlock(&p->app_lock);
if (chan)
ast_channel_free(chan);
if (p->dead)
@@ -226,7 +226,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
struct ast_frame *f = NULL;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->chan) {
p->chan->pvt->rawreadformat = ast->pvt->rawreadformat;
f = ast_read(p->chan);
@@ -270,7 +270,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
f = NULL;
}
CLEANUP(ast,p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
@@ -278,28 +278,28 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
{
struct agent_pvt *p = ast->pvt->pvt;
int res = -1;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->chan) {
p->chan->pvt->rawwriteformat = ast->pvt->rawwriteformat;
res = ast_write(p->chan, f);
} else
res = 0;
CLEANUP(ast, p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
struct agent_pvt *p = newchan->pvt->pvt;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->owner != oldchan) {
ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return -1;
}
p->owner = newchan;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
@@ -307,12 +307,12 @@ static int agent_indicate(struct ast_channel *ast, int condition)
{
struct agent_pvt *p = ast->pvt->pvt;
int res = -1;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->chan)
res = ast_indicate(p->chan, condition);
else
res = 0;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -320,12 +320,12 @@ static int agent_digit(struct ast_channel *ast, char digit)
{
struct agent_pvt *p = ast->pvt->pvt;
int res = -1;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->chan)
res = p->chan->pvt->send_digit(p->chan, digit);
else
res = 0;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -333,7 +333,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
{
struct agent_pvt *p = ast->pvt->pvt;
int res = -1;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (!p->chan) {
if (p->pending) {
ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
@@ -343,7 +343,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
ast_log(LOG_NOTICE, "Whoa, they hung up between alloc and call... what are the odds of that?\n");
res = -1;
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
} else if (strlen(p->loginchan)) {
time(&p->start);
@@ -352,7 +352,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
ast_verbose(VERBOSE_PREFIX_3 "outgoing agentcall, to agent '%s', on '%s'\n", p->agent, p->chan->name);
res = ast_call(p->chan, p->loginchan, 0);
CLEANUP(ast,p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
ast_verbose( VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
@@ -385,7 +385,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
ast_setstate(ast, AST_STATE_UP);
}
CLEANUP(ast,p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -393,7 +393,7 @@ static int agent_hangup(struct ast_channel *ast)
{
struct agent_pvt *p = ast->pvt->pvt;
int howlong = 0;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
p->owner = NULL;
ast->pvt->pvt = NULL;
p->app_sleep_cond = 1;
@@ -415,38 +415,38 @@ static int agent_hangup(struct ast_channel *ast)
strcpy(p->loginchan, "");
}
} else if (p->dead) {
- ast_pthread_mutex_lock(&p->chan->lock);
+ ast_mutex_lock(&p->chan->lock);
ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
- ast_pthread_mutex_unlock(&p->chan->lock);
+ ast_mutex_unlock(&p->chan->lock);
} else {
- ast_pthread_mutex_lock(&p->chan->lock);
+ ast_mutex_lock(&p->chan->lock);
ast_moh_start(p->chan, p->moh);
- ast_pthread_mutex_unlock(&p->chan->lock);
+ ast_mutex_unlock(&p->chan->lock);
}
}
#if 0
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Release ownership of the agent to other threads (presumably running the login app). */
- ast_pthread_mutex_unlock(&p->app_lock);
+ ast_mutex_unlock(&p->app_lock);
} else if (p->dead) {
/* Go ahead and lose it */
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Release ownership of the agent to other threads (presumably running the login app). */
- ast_pthread_mutex_unlock(&p->app_lock);
+ ast_mutex_unlock(&p->app_lock);
} else {
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Release ownership of the agent to other threads (presumably running the login app). */
- ast_pthread_mutex_unlock(&p->app_lock);
+ ast_mutex_unlock(&p->app_lock);
}
#endif
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Release ownership of the agent to other threads (presumably running the login app). */
- ast_pthread_mutex_unlock(&p->app_lock);
+ ast_mutex_unlock(&p->app_lock);
if (p->pending) {
- ast_pthread_mutex_lock(&agentlock);
+ ast_mutex_lock(&agentlock);
agent_unlink(p);
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
}
if (p->abouttograb) {
/* Let the "about to grab" thread know this isn't valid anymore, and let it
@@ -456,11 +456,11 @@ static int agent_hangup(struct ast_channel *ast)
free(p);
} else if (p->chan) {
/* Not dead -- check availability now */
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
/* check_availability(p, 1); */
/* Store last disconnect time */
gettimeofday(&p->lastdisc, NULL);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
}
return 0;
}
@@ -473,7 +473,7 @@ static int agent_cont_sleep( void *data )
p = (struct agent_pvt *)data;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
res = p->app_sleep_cond;
if (p->lastdisc.tv_sec) {
gettimeofday(&tv, NULL);
@@ -481,7 +481,7 @@ static int agent_cont_sleep( void *data )
(tv.tv_usec - p->lastdisc.tv_usec) / 1000 > p->wrapuptime)
res = 1;
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
#if 0
if( !res )
ast_log( LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
@@ -534,9 +534,9 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
tmp->pvt->indicate = agent_indicate;
tmp->pvt->fixup = agent_fixup;
p->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();
tmp->priority = 1;
/* Wake up and wait for other applications (by definition the login app)
@@ -547,13 +547,13 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
* implemented in the kernel for this.
*/
p->app_sleep_cond = 0;
- if( pthread_mutex_trylock(&p->app_lock) )
+ if( ast_mutex_trylock(&p->app_lock) )
{
if (p->chan) {
ast_queue_frame(p->chan, &null_frame, 1);
- ast_pthread_mutex_unlock(&p->lock); /* For other thread to read the condition. */
- ast_pthread_mutex_lock(&p->app_lock);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_unlock(&p->lock); /* For other thread to read the condition. */
+ ast_mutex_lock(&p->app_lock);
+ ast_mutex_lock(&p->lock);
}
if( !p->chan )
{
@@ -562,8 +562,8 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
tmp->pvt->pvt = NULL;
p->app_sleep_cond = 1;
ast_channel_free( tmp );
- ast_pthread_mutex_unlock(&p->lock); /* For other thread to read the condition. */
- ast_pthread_mutex_unlock(&p->app_lock);
+ ast_mutex_unlock(&p->lock); /* For other thread to read the condition. */
+ ast_mutex_unlock(&p->app_lock);
return NULL;
}
}
@@ -596,7 +596,7 @@ static int read_agent_config(void)
ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n");
return 0;
}
- ast_pthread_mutex_lock(&agentlock);
+ ast_mutex_lock(&agentlock);
p = agents;
while(p) {
p->dead = 1;
@@ -648,7 +648,7 @@ static int read_agent_config(void)
pl = p;
p = pn;
}
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
ast_destroy(cfg);
return 0;
}
@@ -660,28 +660,28 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
int res;
ast_log(LOG_DEBUG, "Checking availability of '%s'\n", newlyavailable->agent);
if (needlock)
- ast_pthread_mutex_lock(&agentlock);
+ ast_mutex_lock(&agentlock);
p = agents;
while(p) {
if (p == newlyavailable) {
p = p->next;
continue;
}
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
ast_log(LOG_DEBUG, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
/* We found a pending call, time to merge */
chan = agent_new(newlyavailable, AST_STATE_DOWN);
parent = p->owner;
p->abouttograb = 1;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
break;
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
p = p->next;
}
if (needlock)
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
if (parent && chan) {
ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
res = ast_streamfile(newlyavailable->chan, "beep", newlyavailable->chan->language);
@@ -697,10 +697,10 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
ast_setstate(chan, AST_STATE_UP);
/* Go ahead and mark the channel as a zombie so that masquerade will
destroy it for us, and we need not call ast_hangup */
- ast_pthread_mutex_lock(&parent->lock);
+ ast_mutex_lock(&parent->lock);
chan->zombie = 1;
ast_channel_masquerade(parent, chan);
- ast_pthread_mutex_unlock(&parent->lock);
+ ast_mutex_unlock(&parent->lock);
p->abouttograb = 0;
} else {
ast_log(LOG_DEBUG, "Sneaky, parent disappeared in the mean time...\n");
@@ -732,10 +732,10 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
}
/* Check actual logged in agents first */
- ast_pthread_mutex_lock(&agentlock);
+ ast_mutex_lock(&agentlock);
p = agents;
while(p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) &&
!p->lastdisc.tv_sec && !strlen(p->loginchan)) {
/* Agent must be registered, but not have any active call, and not be in a waiting state */
@@ -749,17 +749,17 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
chan = agent_new(p, AST_STATE_DOWN);
}
if (chan) {
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
break;
}
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
p = p->next;
}
if (!p) {
p = agents;
while(p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) &&
!p->lastdisc.tv_sec) {
/* Agent must be registered, but not have any active call, and not be in a waiting state */
@@ -773,11 +773,11 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
chan = agent_new(p, AST_STATE_DOWN);
}
if (chan) {
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
break;
}
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
p = p->next;
}
}
@@ -793,7 +793,7 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
ast_log(LOG_WARNING, "Weird... Fix this to drop the unused pending agent\n");
}
}
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
return chan;
}
@@ -816,10 +816,10 @@ static int agents_show(int fd, int argc, char **argv)
if (argc != 2)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&agentlock);
+ ast_mutex_lock(&agentlock);
p = agents;
while(p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->pending) {
if (p->group)
ast_cli(fd, "-- Pending call to group %d\n", powerof(p->group));
@@ -851,10 +851,10 @@ static int agents_show(int fd, int argc, char **argv)
ast_cli(fd, "%-12.12s %s%s%s%s\n", p->agent,
username, location, talkingto, moh);
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
p = p->next;
}
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
return RESULT_SUCCESS;
}
@@ -917,14 +917,14 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
}
while (!res && (tries < 3)) {
/* Check for password */
- ast_pthread_mutex_lock(&agentlock);
+ ast_mutex_lock(&agentlock);
p = agents;
while(p) {
if (!strcmp(p->agent, user) && !p->pending)
strncpy(xpass, p->password, sizeof(xpass) - 1);
p = p->next;
}
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
if (!res) {
if (strlen(xpass))
res = ast_app_getdata(chan, "agent-pass", pass, sizeof(pass) - 1, 0);
@@ -938,10 +938,10 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
#endif
/* Check again for accuracy */
- ast_pthread_mutex_lock(&agentlock);
+ ast_mutex_lock(&agentlock);
p = agents;
while(p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (!strcmp(p->agent, user) &&
!strcmp(p->password, pass) && !p->pending) {
if (!p->chan) {
@@ -992,8 +992,8 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
res = ast_waitstream(chan, "");
if (!res)
res = ast_safe_sleep(chan, 1000);
- ast_pthread_mutex_unlock(&p->lock);
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&agentlock);
} else if (!res) {
/* check if the moh class was changed with setmusiconhold */
if (*(chan->musicclass))
@@ -1011,19 +1011,19 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
p->chan = chan;
p->acknowledged = 1;
check_availability(p, 0);
- ast_pthread_mutex_unlock(&p->lock);
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&agentlock);
while (res >= 0) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->chan != chan)
res = -1;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Yield here so other interested threads can kick in. */
sched_yield();
if (res)
break;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->lastdisc.tv_sec) {
gettimeofday(&tv, NULL);
if ((tv.tv_sec - p->lastdisc.tv_sec) * 1000 +
@@ -1033,25 +1033,25 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
check_availability(p, 1);
}
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Synchronize channel ownership between call to agent and itself. */
- pthread_mutex_lock( &p->app_lock );
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock( &p->app_lock );
+ ast_mutex_lock(&p->lock);
p->owning_app = pthread_self();
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
res = ast_safe_sleep_conditional( chan, 1000,
agent_cont_sleep, p );
- pthread_mutex_unlock( &p->app_lock );
+ ast_mutex_unlock( &p->app_lock );
sched_yield();
}
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (res && p->owner)
ast_log(LOG_WARNING, "Huh? We broke out when there was still an owner?\n");
/* Log us off if appropriate */
if (p->chan == chan)
p->chan = NULL;
p->acknowledged = 0;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Agent '%s' logged out\n", p->agent);
manager_event(EVENT_FLAG_AGENT, "Agentlogoff",
@@ -1062,22 +1062,22 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
free(p);
}
else {
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
p = NULL;
}
res = -1;
} else {
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
errmsg = "agent-alreadyon";
p = NULL;
}
break;
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
p = p->next;
}
if (!p)
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
if (!res)
res = ast_app_getdata(chan, errmsg, user, sizeof(user) - 1, 0);
@@ -1127,7 +1127,7 @@ int unload_module()
ast_unregister_application(app);
ast_unregister_application(app2);
ast_channel_unregister(type);
- if (!ast_pthread_mutex_lock(&agentlock)) {
+ if (!ast_mutex_lock(&agentlock)) {
/* Hangup all interfaces if they have an owner */
p = agents;
while(p) {
@@ -1136,7 +1136,7 @@ int unload_module()
p = p->next;
}
agents = NULL;
- ast_pthread_mutex_unlock(&agentlock);
+ ast_mutex_unlock(&agentlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
return -1;
@@ -1147,9 +1147,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;
}
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index dfbce5722..e7ec368b4 100755
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -71,7 +71,7 @@ static int silencethreshold = 1000;
static char digits[80] = "";
static char text2send[80] = "";
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *type = "Console";
static char *desc = "ALSA Console Channel Driver";
@@ -518,9 +518,9 @@ static int alsa_hangup(struct ast_channel *c)
c->pvt->pvt = NULL;
alsa.owner = NULL;
ast_verbose( " << Hangup on console >> \n");
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt--;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
needhangup = 0;
needanswer = 0;
if (hookstate) {
@@ -807,9 +807,9 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
strncpy(tmp->language, language, sizeof(tmp->language)-1);
p->owner = tmp;
ast_setstate(tmp, state);
- 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();
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
@@ -1103,9 +1103,9 @@ char *description()
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;
}
diff --git a/channels/chan_iax.c b/channels/chan_iax.c
index b9869916a..1d1c354bb 100755
--- a/channels/chan_iax.c
+++ b/channels/chan_iax.c
@@ -91,7 +91,7 @@ static int tos = 0;
static int expirey = AST_DEFAULT_REG_EXPIRE;
static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
int (*iax_regfunk)(char *username, int onoff) = NULL;
@@ -384,17 +384,17 @@ static struct ast_iax_queue {
struct ast_iax_frame *head;
struct ast_iax_frame *tail;
int count;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} iaxq;
static struct ast_user_list {
struct iax_user *users;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} userl;
static struct ast_peer_list {
struct iax_peer *peers;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} peerl;
/* Extension exists */
@@ -426,7 +426,7 @@ static struct iax_dpcache {
struct iax_dpcache *peer; /* For linking in peers */
} *dpcache;
-static pthread_mutex_t dpcache_lock;
+static ast_mutex_t dpcache_lock;
#ifdef DEBUG_SUPPORT
static void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int rx, struct sockaddr_in *sin)
@@ -541,7 +541,7 @@ static void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int
/* XXX We probably should use a mutex when working with this XXX */
static struct chan_iax_pvt *iaxs[AST_IAX_MAX_CALLS];
-static pthread_mutex_t iaxsl[AST_IAX_MAX_CALLS];
+static ast_mutex_t iaxsl[AST_IAX_MAX_CALLS];
static int send_command(struct chan_iax_pvt *, char, int, unsigned int, char *, int, int);
static int send_command_immediate(struct chan_iax_pvt *, char, int, unsigned int, char *, int, int);
@@ -767,14 +767,14 @@ static int find_callno(short callno, short dcallno ,struct sockaddr_in *sin, int
if (new <= NEW_ALLOW) {
/* Look for an existing connection first */
for (x=0;(res < 0) && (x<AST_IAX_MAX_CALLS);x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
/* Look for an exact match */
if (match(sin, callno, dcallno, iaxs[x])) {
res = x;
}
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
}
if ((res < 0) && (new >= NEW_ALLOW)) {
@@ -785,9 +785,9 @@ static int find_callno(short callno, short dcallno ,struct sockaddr_in *sin, int
ast_log(LOG_WARNING, "Unable to accept more calls\n");
return -1;
}
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
iaxs[x] = new_iax();
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
if (iaxs[x]) {
if (option_debug)
ast_log(LOG_DEBUG, "Creating new call structure %d\n", x);
@@ -818,19 +818,19 @@ static int iax_queue_frame(int callno, struct ast_frame *f)
/* Assumes lock for callno is already held... */
for (;;) {
pass++;
- if (!pthread_mutex_trylock(&iaxsl[callno])) {
+ if (!ast_mutex_trylock(&iaxsl[callno])) {
ast_log(LOG_WARNING, "Lock is not held on pass %d of iax_queue_frame\n", pass);
CRASH;
}
if (iaxs[callno] && iaxs[callno]->owner) {
- if (pthread_mutex_trylock(&iaxs[callno]->owner->lock)) {
+ if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
/* Avoid deadlock by pausing and trying again */
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
} else {
ast_queue_frame(iaxs[callno]->owner, f, 0);
- ast_pthread_mutex_unlock(&iaxs[callno]->owner->lock);
+ ast_mutex_unlock(&iaxs[callno]->owner->lock);
break;
}
} else
@@ -879,9 +879,9 @@ static int do_deliver(void *data)
struct ast_iax_frame *fr = data;
int callno = fr->callno;
int res;
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
res = __do_deliver(data);
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return res;
}
@@ -963,10 +963,10 @@ static int iax_predestroy(int callno)
{
struct ast_channel *c;
struct chan_iax_pvt *pvt;
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
if (!pvt) {
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return -1;
}
if (!pvt->alreadygone) {
@@ -990,23 +990,23 @@ static int iax_predestroy(int callno)
c->_softhangup |= AST_SOFTHANGUP_DEV;
c->pvt->pvt = NULL;
pvt->owner = NULL;
- 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();
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
static int iax_predestroy_nolock(int callno)
{
int res;
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
res = iax_predestroy(callno);
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
return res;
}
@@ -1017,7 +1017,7 @@ static void iax_destroy(int callno)
struct ast_channel *owner;
retry:
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
iaxs[callno] = NULL;
@@ -1026,9 +1026,9 @@ retry:
else
owner = NULL;
if (owner) {
- if (pthread_mutex_trylock(&owner->lock)) {
+ if (ast_mutex_trylock(&owner->lock)) {
ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
goto retry;
}
@@ -1070,16 +1070,16 @@ retry:
free(pvt);
}
if (owner) {
- ast_pthread_mutex_unlock(&owner->lock);
+ ast_mutex_unlock(&owner->lock);
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
}
static void iax_destroy_nolock(int callno)
{
/* Actually it's easier to unlock, kill it, and relock */
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
iax_destroy(callno);
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
}
@@ -1093,7 +1093,7 @@ static int attempt_transmit(void *data)
int callno = f->callno;
/* Make sure this call is still active */
if (callno > -1)
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
if ((f->callno > -1) && iaxs[f->callno]) {
if ((f->retries < 0) /* Already ACK'd */ ||
(f->retries >= max_retries) /* Too many attempts */) {
@@ -1146,11 +1146,11 @@ static int attempt_transmit(void *data)
freeme++;
}
if (callno > -1)
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
/* Do not try again */
if (freeme) {
/* Don't attempt delivery, just remove it from the queue */
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
if (f->prev)
f->prev->next = f->next;
else
@@ -1160,7 +1160,7 @@ static int attempt_transmit(void *data)
else
iaxq.tail = f->prev;
iaxq.count--;
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
/* Free the frame */
ast_frfree(f->f);
f->retrans = -1;
@@ -1228,7 +1228,7 @@ static int iax_show_cache(int fd, int argc, char *argv[])
int x,y;
struct timeval tv;
gettimeofday(&tv, NULL);
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = dpcache;
ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8.8s %s\n", "Peer/Context", "Exten", "Exp.", "Wait.", "Flags");
while(dp) {
@@ -1270,7 +1270,7 @@ static int iax_show_cache(int fd, int argc, char *argv[])
ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->exten, "(expired)", y, tmp);
dp = dp->next;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
return RESULT_SUCCESS;
}
@@ -1453,7 +1453,7 @@ static int iax_transmit(struct ast_iax_frame *fr)
/* By setting this to 0, the network thread will send it for us, and
queue retransmission if necessary */
fr->sentyet = 0;
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
if (!iaxq.head) {
/* Empty queue */
iaxq.head = fr;
@@ -1465,7 +1465,7 @@ static int iax_transmit(struct ast_iax_frame *fr)
iaxq.tail = fr;
}
iaxq.count++;
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
/* Wake up the network thread */
pthread_kill(netthreadid, SIGURG);
return 0;
@@ -1512,7 +1512,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
if (maxtime)
*maxtime = 0;
sin->sin_family = AF_INET;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
p = peerl.peers;
while(p) {
if (!strcasecmp(p->name, peer)) {
@@ -1539,7 +1539,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
hp = gethostbyname(peer);
if (hp) {
@@ -1560,13 +1560,13 @@ static int auto_congest(void *nothing)
{
int callno = (int)(long)(nothing);
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_CONGESTION };
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
iaxs[callno]->initid = -1;
iax_queue_frame(callno, &f);
ast_log(LOG_NOTICE, "Auto-congesting call due to slow response\n");
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
@@ -1683,7 +1683,7 @@ static int iax_hangup(struct ast_channel *c)
int callno;
if (pvt) {
callno = pvt->callno;
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
alreadygone = pvt->alreadygone;
/* Send the hangup unless we have had a transmission error or are already gone */
@@ -1696,7 +1696,7 @@ static int iax_hangup(struct ast_channel *c)
ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
iax_destroy_nolock(callno);
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
}
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Hungup '%s'\n", c->name);
@@ -1886,7 +1886,7 @@ static int iax_getpeername(struct sockaddr_in sin, char *host, int len)
{
struct iax_peer *peer;
int res = 0;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
@@ -1897,7 +1897,7 @@ static int iax_getpeername(struct sockaddr_in sin, char *host, int len)
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
@@ -1950,9 +1950,9 @@ static struct ast_channel *ast_iax_new(struct chan_iax_pvt *i, int state, int ca
i->owner = tmp;
i->capability = capability;
ast_setstate(tmp, state);
- 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();
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
@@ -2142,14 +2142,14 @@ static int iax_show_users(int fd, int argc, char *argv[])
struct iax_user *user;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
ast_cli(fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C");
for(user=userl.users;user;user=user->next) {
ast_cli(fd, FORMAT, user->name, user->secret, user->methods,
user->contexts ? user->contexts->context : context,
user->ha ? "Yes" : "No");
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return RESULT_SUCCESS;
#undef FORMAT
}
@@ -2162,7 +2162,7 @@ static int iax_show_peers(int fd, int argc, char *argv[])
char name[256] = "";
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", "Status");
for (peer = peerl.peers;peer;peer = peer->next) {
char nm[20];
@@ -2189,7 +2189,7 @@ static int iax_show_peers(int fd, int argc, char *argv[])
nm,
ntohs(peer->addr.sin_port), status);
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -2236,7 +2236,7 @@ static int iax_show_registry(int fd, int argc, char *argv[])
char perceived[80];
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
ast_cli(fd, FORMAT2, "Host", "Username", "Perceived", "Refresh", "State");
for (reg = registrations;reg;reg = reg->next) {
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
@@ -2247,7 +2247,7 @@ static int iax_show_registry(int fd, int argc, char *argv[])
ast_cli(fd, FORMAT, host,
reg->username, perceived, reg->refresh, regstate2str(reg->regstate));
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -2263,7 +2263,7 @@ static int iax_show_channels(int fd, int argc, char *argv[])
return RESULT_SHOWUSAGE;
ast_cli(fd, FORMAT2, "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
for (x=0;x<AST_IAX_MAX_CALLS;x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
ast_cli(fd, FORMAT, inet_ntoa(iaxs[x]->addr.sin_addr),
strlen(iaxs[x]->username) ? iaxs[x]->username : "(None)",
@@ -2274,7 +2274,7 @@ static int iax_show_channels(int fd, int argc, char *argv[])
iaxs[x]->voiceformat);
numchans++;
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
ast_cli(fd, "%d active IAX channel(s)\n", numchans);
return RESULT_SUCCESS;
@@ -2499,7 +2499,7 @@ static int check_access(int callno, struct sockaddr_in *sin, char *orequest, int
inet_ntoa(sin->sin_addr), version);
return res;
}
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
/* Search the userlist for a compatible entry, and fill in the rest */
user = userl.users;
while(user) {
@@ -2541,7 +2541,7 @@ static int check_access(int callno, struct sockaddr_in *sin, char *orequest, int
}
user = user->next;
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return res;
}
@@ -2860,7 +2860,7 @@ static int authenticate_reply(struct chan_iax_pvt *p, struct sockaddr_in *sin, c
/* Normal password authentication */
res = authenticate(p->challenge, override, okey, methods, requeststr, sizeof(requeststr), sin);
} else {
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if ((!strlen(p->peer) || !strcmp(p->peer, peer->name))
@@ -2876,7 +2876,7 @@ static int authenticate_reply(struct chan_iax_pvt *p, struct sockaddr_in *sin, c
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
if (strlen(requeststr))
requeststr[strlen(requeststr)-1] = '\0';
@@ -2983,7 +2983,7 @@ static int complete_dpreply(struct chan_iax_pvt *pvt, char *orequest)
}
var = strsep(&stringp, ";");
}
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
prev = NULL;
dp = pvt->dpentries;
while(dp) {
@@ -3009,7 +3009,7 @@ static int complete_dpreply(struct chan_iax_pvt *pvt, char *orequest)
prev = dp;
dp = dp->peer;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
return 0;
}
@@ -3063,7 +3063,7 @@ static int complete_transfer(int callno, char *orequest)
pvt->last = 0;
pvt->lastsent = 0;
pvt->pingtime = DEFAULT_RETRY_TIME;
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
for (cur = iaxq.head; cur ; cur = cur->next) {
/* We must cancel any packets that would have been transmitted
because now we're talking to someone new. It's okay, they
@@ -3071,7 +3071,7 @@ static int complete_transfer(int callno, char *orequest)
if (callno == cur->callno)
cur->retries = -1;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
return 0;
}
@@ -3353,12 +3353,12 @@ static int auto_hangup(void *nothing)
{
/* Called from IAX thread only, without iaxs lock */
int callno = (int)(long)(nothing);
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
iaxs[callno]->autoid = -1;
send_command_final(iaxs[callno], AST_FRAME_IAX, AST_IAX_COMMAND_HANGUP, 0, "Timeout", strlen("Timeout") + 1, -1);
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
@@ -3380,7 +3380,7 @@ static int iax_vnak(int callno)
static void vnak_retransmit(int callno, int last)
{
struct ast_iax_frame *f;
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
f = iaxq.head;
while(f) {
/* Send a copy immediately */
@@ -3390,7 +3390,7 @@ static void vnak_retransmit(int callno, int last)
}
f = f->next;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
}
static int iax_poke_peer_s(void *data)
@@ -3460,7 +3460,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
fr.callno = find_callno(ntohs(mh->callno) & ~AST_FLAG_FULL, dcallno, &sin, new);
if (fr.callno > 0)
- ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+ ast_mutex_lock(&iaxsl[fr.callno]);
if ((fr.callno < 0) || !iaxs[fr.callno]) {
/* A call arrived for a non-existant destination. Unless it's an "inval"
@@ -3475,7 +3475,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
);
}
if (fr.callno > 0)
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
if (((f.subclass != AST_IAX_COMMAND_TXCNT) &&
@@ -3515,7 +3515,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
/* Send a VNAK requesting retransmission */
iax_vnak(fr.callno);
}
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
} else {
@@ -3531,7 +3531,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
/* A full frame */
if (res < sizeof(struct ast_iax_full_hdr)) {
ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, sizeof(struct ast_iax_full_hdr));
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
f.datalen = res - sizeof(struct ast_iax_full_hdr);
@@ -3553,13 +3553,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
if (iaxs[fr.callno]->owner) {
int orignative;
- ast_pthread_mutex_lock(&iaxs[fr.callno]->owner->lock);
+ ast_mutex_lock(&iaxs[fr.callno]->owner->lock);
orignative = iaxs[fr.callno]->owner->nativeformats;
iaxs[fr.callno]->owner->nativeformats = f.subclass;
if (iaxs[fr.callno]->owner->readformat)
ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
iaxs[fr.callno]->owner->nativeformats = orignative;
- ast_pthread_mutex_unlock(&iaxs[fr.callno]->owner->lock);
+ ast_mutex_unlock(&iaxs[fr.callno]->owner->lock);
}
}
}
@@ -3579,7 +3579,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
switch(f.subclass) {
case AST_IAX_COMMAND_ACK:
/* Ack the packet with the given timestamp */
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
for (cur = iaxq.head; cur ; cur = cur->next) {
/* If it's our call, and our timestamp, mark -1 retries */
if ((fr.callno == cur->callno) && (fr.seqno == cur->seqno)) {
@@ -3592,7 +3592,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
}
}
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
break;
case AST_IAX_COMMAND_QUELCH:
if (iaxs[fr.callno]->state & IAX_STATE_STARTED)
@@ -3605,13 +3605,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
case AST_IAX_COMMAND_TXACC:
if (iaxs[fr.callno]->transferring == TRANSFER_BEGIN) {
/* Ack the packet with the given timestamp */
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
for (cur = iaxq.head; cur ; cur = cur->next) {
/* Cancel any outstanding txcnt's */
if ((fr.callno == cur->callno) && (cur->transfer))
cur->retries = -1;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
snprintf(rel1, sizeof(rel1), "callno=%d;", iaxs[fr.callno]->callno);
send_command(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_TXREADY, 0, rel1, strlen(rel1) + 1, -1);
iaxs[fr.callno]->transferring = TRANSFER_READY;
@@ -3745,7 +3745,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
}
}
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = iaxs[fr.callno]->dpentries;
while(dp) {
if (!(dp->flags & CACHE_FLAG_TRANSMITTED)) {
@@ -3753,7 +3753,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
}
dp = dp->peer;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
break;
case AST_IAX_COMMAND_POKE:
/* Send back a pong packet with the original timestamp */
@@ -4030,7 +4030,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
ast_log(LOG_DEBUG, "Unknown IAX command %d on %d/%d\n", f.subclass, fr.callno, iaxs[fr.callno]->peercallno);
}
/* Don't actually pass these frames along */
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
} else {
@@ -4041,13 +4041,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
else {
ast_log(LOG_WARNING, "Received mini frame before first full voice frame\n ");
iax_vnak(fr.callno);
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
f.datalen = res - sizeof(struct ast_iax_mini_hdr);
if (f.datalen < 0) {
ast_log(LOG_WARNING, "Datalen < 0?\n");
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
if (f.datalen)
@@ -4058,7 +4058,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
}
/* Don't pass any packets until we're started */
if (!(iaxs[fr.callno]->state & IAX_STATE_STARTED)) {
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
/* Common things */
@@ -4090,7 +4090,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
schedule_delivery(iaxfrdup2(&fr, 0), 1);
#endif
/* Always run again */
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
@@ -4209,12 +4209,12 @@ static struct ast_channel *iax_request(char *type, int format, void *data)
ast_log(LOG_WARNING, "Unable to create call\n");
return NULL;
}
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
/* Keep track of sendani flag */
iaxs[callno]->sendani = sendani;
iaxs[callno]->maxtime = maxtime;
c = ast_iax_new(iaxs[callno], AST_STATE_DOWN, capability);
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
if (c) {
/* Choose a format we can live with */
if (c->nativeformats & format)
@@ -4245,7 +4245,7 @@ static void *network_thread(void *ignore)
for(;;) {
/* Go through the queue, sending messages which have not yet been
sent, and scheduling retransmissions if appropriate */
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
f = iaxq.head;
while(f) {
freeme = NULL;
@@ -4281,7 +4281,7 @@ static void *network_thread(void *ignore)
if (freeme)
ast_iax_frame_free(freeme);
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
res = ast_sched_wait(sched);
if ((res > 1000) || (res < 0))
res = 1000;
@@ -4316,7 +4316,7 @@ static struct iax_peer *build_peer(char *name, struct ast_variable *v)
int format;
int found=0;
prev = NULL;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!strcasecmp(peer->name, name)) {
@@ -4333,9 +4333,9 @@ static struct iax_peer *build_peer(char *name, struct ast_variable *v)
} else {
peerl.peers = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
} else {
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
peer = malloc(sizeof(struct iax_peer));
memset(peer, 0, sizeof(struct iax_peer));
peer->expire = -1;
@@ -4507,7 +4507,7 @@ static void delete_users(void){
struct iax_registry *reg, *regl;
/* Delete all users */
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
for (user=userl.users;user;) {
ast_free_ha(user->ha);
free_context(user->contexts);
@@ -4516,7 +4516,7 @@ static void delete_users(void){
free(userlast);
}
userl.users=NULL;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
for (reg = registrations;reg;) {
regl = reg;
@@ -4526,30 +4526,30 @@ static void delete_users(void){
free(regl);
}
registrations = NULL;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer=peerl.peers;peer;) {
/* Assume all will be deleted, and we'll find out for sure later */
peer->delme = 1;
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
static void prune_peers(void){
/* Prune peers who still are supposed to be deleted */
struct iax_peer *peer, *peerlast, *peernext;
int x;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peerlast = NULL;
for (peer=peerl.peers;peer;) {
peernext = peer->next;
if (peer->delme) {
for (x=0;x<AST_IAX_MAX_CALLS;x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (iaxs[x] && (iaxs[x]->peerpoke == peer)) {
iax_destroy(x);
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
/* Delete it, it needs to disappear */
if (peer->expire > -1)
@@ -4567,7 +4567,7 @@ static void prune_peers(void){
peerlast = peer;
peer=peernext;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
@@ -4675,19 +4675,19 @@ static int set_config(char *config_file, struct sockaddr_in* sin){
if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
user = build_user(cat, ast_variable_browse(cfg, cat));
if (user) {
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user->next = userl.users;
userl.users = user;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
}
}
if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
peer = build_peer(cat, ast_variable_browse(cfg, cat));
if (peer) {
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer->next = peerl.peers;
peerl.peers = peer;
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
} else if (strcasecmp(utype, "user")) {
ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, config_file);
@@ -4736,12 +4736,12 @@ static int cache_get_callno(char *data)
for (x=0;x<AST_IAX_MAX_CALLS; x++) {
/* Look for an *exact match* call. Once a call is negotiated, it can only
look up entries for a single context */
- if (!pthread_mutex_trylock(&iaxsl[x])) {
+ if (!ast_mutex_trylock(&iaxsl[x])) {
if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot)) {
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
return x;
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
}
/* No match found, we need to create a new one */
@@ -4779,7 +4779,7 @@ static int cache_get_callno(char *data)
ast_log(LOG_WARNING, "Unable to create call\n");
return -1;
}
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
strncpy(iaxs[callno]->dproot, data, sizeof(iaxs[callno]->dproot)-1);
iaxs[callno]->capability = IAX_CAPABILITY_FULLBANDWIDTH;
MYSNPRINTF "exten=TBD;");
@@ -4800,7 +4800,7 @@ static int cache_get_callno(char *data)
ast_verbose(VERBOSE_PREFIX_3 "Calling TBD using options '%s'\n", requeststr);
/* Start the call going */
send_command(iaxs[callno], AST_FRAME_IAX, AST_IAX_COMMAND_NEW, 0, requeststr, strlen(requeststr) + 1, -1);
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return callno;
}
@@ -4895,7 +4895,7 @@ static struct iax_dpcache *find_cache(struct ast_channel *chan, char *data, char
/* Okay, now we wait */
timeout = iaxdefaulttimeout * 1000;
/* Temporarily unlock */
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
/* Defer any dtmf */
if (chan)
old = ast_channel_defer_dtmf(chan);
@@ -4919,7 +4919,7 @@ static struct iax_dpcache *find_cache(struct ast_channel *chan, char *data, char
if (!timeout) {
ast_log(LOG_WARNING, "Timeout waiting for %s exten %s\n", data, exten);
}
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp->waiters[x] = -1;
close(com[1]);
close(com[0]);
@@ -4961,13 +4961,13 @@ static int iax_exists(struct ast_channel *chan, char *context, char *exten, int
#endif
if (priority != 1)
return 0;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_EXISTS)
res= 1;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
if (!dp) {
ast_log(LOG_WARNING, "Unable to make DP cache\n");
}
@@ -4983,13 +4983,13 @@ static int iax_canmatch(struct ast_channel *chan, char *context, char *exten, in
#endif
if (priority != 1)
return 0;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_CANEXIST)
res= 1;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
if (!dp) {
ast_log(LOG_WARNING, "Unable to make DP cache\n");
}
@@ -5005,13 +5005,13 @@ static int iax_matchmore(struct ast_channel *chan, char *context, char *exten, i
#endif
if (priority != 1)
return 0;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_MATCHMORE)
res= 1;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
if (!dp) {
ast_log(LOG_WARNING, "Unable to make DP cache\n");
}
@@ -5030,7 +5030,7 @@ static int iax_exec(struct ast_channel *chan, char *context, char *exten, int pr
#endif
if (priority != 1)
return -1;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_EXISTS) {
@@ -5046,12 +5046,12 @@ static int iax_exec(struct ast_channel *chan, char *context, char *exten, int pr
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Executing Dial('%s')\n", req);
} else {
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
ast_log(LOG_WARNING, "Can't execute non-existant extension '%s[@%s]' in data '%s'\n", exten, context, data);
return -1;
}
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
dial = pbx_findapp("Dial");
if (dial) {
pbx_exec(chan, dial, req, newstack);
@@ -5089,7 +5089,7 @@ int load_module(void)
sin.sin_addr.s_addr = INADDR_ANY;
for (x=0;x<AST_IAX_MAX_CALLS;x++)
- ast_pthread_mutex_init(&iaxsl[x]);
+ ast_mutex_init(&iaxsl[x]);
io = io_context_create();
sched = sched_context_create();
@@ -5099,10 +5099,10 @@ int load_module(void)
return -1;
}
- ast_pthread_mutex_init(&iaxq.lock);
- ast_pthread_mutex_init(&userl.lock);
- ast_pthread_mutex_init(&peerl.lock);
- ast_pthread_mutex_init(&dpcache_lock);
+ ast_mutex_init(&iaxq.lock);
+ ast_mutex_init(&userl.lock);
+ ast_mutex_init(&peerl.lock);
+ ast_mutex_init(&dpcache_lock);
ast_cli_register(&cli_show_users);
ast_cli_register(&cli_show_channels);
@@ -5155,10 +5155,10 @@ int load_module(void)
}
for (reg = registrations; reg; reg = reg->next)
iax_do_register(reg);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer = peerl.peers; peer; peer = peer->next)
iax_poke_peer(peer);
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
@@ -5192,9 +5192,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;
}
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 83f4723af..b6feec094 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -107,7 +107,7 @@ static int expirey = IAX_DEFAULT_REG_EXPIRE;
static int timingfd = -1; /* Timing file descriptor */
static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
int (*iax2_regfunk)(char *username, int onoff) = NULL;
@@ -397,17 +397,17 @@ static struct ast_iax2_queue {
struct iax_frame *head;
struct iax_frame *tail;
int count;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} iaxq;
static struct ast_user_list {
struct iax2_user *users;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} userl;
static struct ast_peer_list {
struct iax2_peer *peers;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} peerl;
/* Extension exists */
@@ -439,7 +439,7 @@ static struct iax2_dpcache {
struct iax2_dpcache *peer; /* For linking in peers */
} *dpcache;
-static pthread_mutex_t dpcache_lock;
+static ast_mutex_t dpcache_lock;
static void iax_debug_output(const char *data)
{
@@ -453,7 +453,7 @@ static void iax_error_output(const char *data)
/* XXX We probably should use a mutex when working with this XXX */
static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS];
-static pthread_mutex_t iaxsl[IAX_MAX_CALLS];
+static ast_mutex_t iaxsl[IAX_MAX_CALLS];
static struct timeval lastused[IAX_MAX_CALLS];
@@ -531,7 +531,7 @@ static int iax2_getpeername(struct sockaddr_in sin, char *host, int len, int loc
struct iax2_peer *peer;
int res = 0;
if (lockpeer)
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
@@ -543,7 +543,7 @@ static int iax2_getpeername(struct sockaddr_in sin, char *host, int len, int loc
peer = peer->next;
}
if (lockpeer)
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
@@ -692,7 +692,7 @@ static int make_trunk(unsigned short callno, int locked)
}
gettimeofday(&now, NULL);
for (x=TRUNK_CALL_START;x<IAX_MAX_CALLS - 1; x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (!iaxs[x] && ((now.tv_sec - lastused[x].tv_sec) > MIN_REUSE_TIME)) {
iaxs[x] = iaxs[callno];
iaxs[x]->callno = x;
@@ -705,13 +705,13 @@ static int make_trunk(unsigned short callno, int locked)
iaxs[x]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, (void *)x);
iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)x);
if (locked)
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
res = x;
if (!locked)
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
break;
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
if (x >= IAX_MAX_CALLS - 1) {
ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
@@ -732,33 +732,33 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
if (new <= NEW_ALLOW) {
/* Look for an existing connection first */
for (x=1;(res < 1) && (x<maxnontrunkcall);x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
/* Look for an exact match */
if (match(sin, callno, dcallno, iaxs[x])) {
res = x;
}
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
for (x=TRUNK_CALL_START;(res < 1) && (x<maxtrunkcall);x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
/* Look for an exact match */
if (match(sin, callno, dcallno, iaxs[x])) {
res = x;
}
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
}
if ((res < 1) && (new >= NEW_ALLOW)) {
gettimeofday(&now, NULL);
for (x=1;x<TRUNK_CALL_START;x++) {
/* Find first unused call number that hasn't been used in a while */
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (!iaxs[x] && ((now.tv_sec - lastused[x].tv_sec) > MIN_REUSE_TIME)) break;
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
/* We've still got lock held if we found a spot */
if (x >= TRUNK_CALL_START) {
@@ -766,7 +766,7 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
return -1;
}
iaxs[x] = new_iax(sin, lockpeer);
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
update_max_nontrunk();
if (iaxs[x]) {
if (option_debug)
@@ -805,19 +805,19 @@ static int iax2_queue_frame(int callno, struct ast_frame *f)
/* Assumes lock for callno is already held... */
for (;;) {
pass++;
- if (!pthread_mutex_trylock(&iaxsl[callno])) {
+ if (!ast_mutex_trylock(&iaxsl[callno])) {
ast_log(LOG_WARNING, "Lock is not held on pass %d of iax2_queue_frame\n", pass);
CRASH;
}
if (iaxs[callno] && iaxs[callno]->owner) {
- if (pthread_mutex_trylock(&iaxs[callno]->owner->lock)) {
+ if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
/* Avoid deadlock by pausing and trying again */
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
} else {
ast_queue_frame(iaxs[callno]->owner, f, 0);
- ast_pthread_mutex_unlock(&iaxs[callno]->owner->lock);
+ ast_mutex_unlock(&iaxs[callno]->owner->lock);
break;
}
} else
@@ -864,9 +864,9 @@ static int do_deliver(void *data)
struct iax_frame *fr = data;
int callno = fr->callno;
int res;
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
res = __do_deliver(data);
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return res;
}
@@ -944,10 +944,10 @@ static int iax2_predestroy(int callno)
{
struct ast_channel *c;
struct chan_iax2_pvt *pvt;
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
if (!pvt) {
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return -1;
}
if (!pvt->alreadygone) {
@@ -972,23 +972,23 @@ static int iax2_predestroy(int callno)
c->pvt->pvt = NULL;
ast_queue_hangup(c, 0);
pvt->owner = NULL;
- 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();
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
static int iax2_predestroy_nolock(int callno)
{
int res;
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
res = iax2_predestroy(callno);
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
return res;
}
@@ -999,7 +999,7 @@ static void iax2_destroy(int callno)
struct ast_channel *owner;
retry:
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
gettimeofday(&lastused[callno], NULL);
@@ -1008,9 +1008,9 @@ retry:
else
owner = NULL;
if (owner) {
- if (pthread_mutex_trylock(&owner->lock)) {
+ if (ast_mutex_trylock(&owner->lock)) {
ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
goto retry;
}
@@ -1053,18 +1053,18 @@ retry:
free(pvt);
}
if (owner) {
- ast_pthread_mutex_unlock(&owner->lock);
+ ast_mutex_unlock(&owner->lock);
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
if (callno & 0x4000)
update_max_trunk();
}
static void iax2_destroy_nolock(int callno)
{
/* Actually it's easier to unlock, kill it, and relock */
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
iax2_destroy(callno);
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
}
static int update_packet(struct iax_frame *f)
@@ -1088,7 +1088,7 @@ static int attempt_transmit(void *data)
int callno = f->callno;
/* Make sure this call is still active */
if (callno)
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
if ((f->callno) && iaxs[f->callno]) {
if ((f->retries < 0) /* Already ACK'd */ ||
(f->retries >= max_retries) /* Too many attempts */) {
@@ -1143,11 +1143,11 @@ static int attempt_transmit(void *data)
freeme++;
}
if (callno)
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
/* Do not try again */
if (freeme) {
/* Don't attempt delivery, just remove it from the queue */
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
if (f->prev)
f->prev->next = f->next;
else
@@ -1157,7 +1157,7 @@ static int attempt_transmit(void *data)
else
iaxq.tail = f->prev;
iaxq.count--;
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
f->retrans = -1;
/* Free the IAX frame */
iax2_frame_free(f);
@@ -1224,7 +1224,7 @@ static int iax2_show_cache(int fd, int argc, char *argv[])
int x,y;
struct timeval tv;
gettimeofday(&tv, NULL);
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = dpcache;
ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8.8s %s\n", "Peer/Context", "Exten", "Exp.", "Wait.", "Flags");
while(dp) {
@@ -1266,7 +1266,7 @@ static int iax2_show_cache(int fd, int argc, char *argv[])
ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8d %s\n", pc, dp->exten, "(expired)", y, tmp);
dp = dp->next;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
return RESULT_SUCCESS;
}
@@ -1449,7 +1449,7 @@ static int iax2_transmit(struct iax_frame *fr)
/* By setting this to 0, the network thread will send it for us, and
queue retransmission if necessary */
fr->sentyet = 0;
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
if (!iaxq.head) {
/* Empty queue */
iaxq.head = fr;
@@ -1461,7 +1461,7 @@ static int iax2_transmit(struct iax_frame *fr)
iaxq.tail = fr;
}
iaxq.count++;
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
/* Wake up the network thread */
pthread_kill(netthreadid, SIGURG);
return 0;
@@ -1510,7 +1510,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
if (trunk)
*trunk = 0;
sin->sin_family = AF_INET;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
p = peerl.peers;
while(p) {
if (!strcasecmp(p->name, peer)) {
@@ -1543,7 +1543,7 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
hp = gethostbyname(peer);
if (hp) {
@@ -1564,13 +1564,13 @@ static int auto_congest(void *nothing)
{
int callno = (int)(long)(nothing);
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_CONGESTION };
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
iaxs[callno]->initid = -1;
iax2_queue_frame(callno, &f);
ast_log(LOG_NOTICE, "Auto-congesting call due to slow response\n");
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
@@ -1718,7 +1718,7 @@ static int iax2_hangup(struct ast_channel *c)
int callno;
if (pvt) {
callno = pvt->callno;
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
alreadygone = pvt->alreadygone;
/* Send the hangup unless we have had a transmission error or are already gone */
@@ -1731,7 +1731,7 @@ static int iax2_hangup(struct ast_channel *c)
ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
iax2_destroy_nolock(callno);
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
}
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Hungup '%s'\n", c->name);
@@ -1965,7 +1965,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin)
{
struct iax2_peer *peer;
int res = 0;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
@@ -1975,7 +1975,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin)
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
@@ -2027,9 +2027,9 @@ static struct ast_channel *ast_iax2_new(struct chan_iax2_pvt *i, int state, int
i->owner = tmp;
i->capability = capability;
ast_setstate(tmp, state);
- 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();
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
@@ -2309,14 +2309,14 @@ static int iax2_show_users(int fd, int argc, char *argv[])
struct iax2_user *user;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
ast_cli(fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C");
for(user=userl.users;user;user=user->next) {
ast_cli(fd, FORMAT2, user->name, user->secret, user->authmethods,
user->contexts ? user->contexts->context : context,
user->ha ? "Yes" : "No");
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -2337,7 +2337,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
} else
return RESULT_SHOWUSAGE;
}
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", "Status");
for (peer = peerl.peers;peer;peer = peer->next) {
char nm[20];
@@ -2366,7 +2366,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
nm,
ntohs(peer->addr.sin_port), peer->trunk ? "(T)" : " ", status);
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -2413,7 +2413,7 @@ static int iax2_show_registry(int fd, int argc, char *argv[])
char perceived[80];
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
ast_cli(fd, FORMAT2, "Host", "Username", "Perceived", "Refresh", "State");
for (reg = registrations;reg;reg = reg->next) {
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
@@ -2424,7 +2424,7 @@ static int iax2_show_registry(int fd, int argc, char *argv[])
ast_cli(fd, FORMAT, host,
reg->username, perceived, reg->refresh, regstate2str(reg->regstate));
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -2440,7 +2440,7 @@ static int iax2_show_channels(int fd, int argc, char *argv[])
return RESULT_SHOWUSAGE;
ast_cli(fd, FORMAT2, "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
for (x=0;x<IAX_MAX_CALLS;x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
ast_cli(fd, FORMAT, inet_ntoa(iaxs[x]->addr.sin_addr),
strlen(iaxs[x]->username) ? iaxs[x]->username : "(None)",
@@ -2451,7 +2451,7 @@ static int iax2_show_channels(int fd, int argc, char *argv[])
iaxs[x]->voiceformat);
numchans++;
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
ast_cli(fd, "%d active IAX channel(s)\n", numchans);
return RESULT_SUCCESS;
@@ -2654,7 +2654,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
inet_ntoa(sin->sin_addr), version);
return res;
}
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
/* Search the userlist for a compatible entry, and fill in the rest */
user = userl.users;
while(user) {
@@ -2699,7 +2699,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
}
user = user->next;
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
iaxs[callno]->trunk = iax2_getpeertrunk(*sin);
return res;
}
@@ -2970,7 +2970,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct sockaddr_in *sin,
/* Normal password authentication */
res = authenticate(p->challenge, override, okey, authmethods, &ied, sin);
} else {
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if ((!strlen(p->peer) || !strcmp(p->peer, peer->name))
@@ -2986,7 +2986,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct sockaddr_in *sin,
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
if (!res)
res = send_command(p, AST_FRAME_IAX, IAX_COMMAND_AUTHREP, 0, ied.buf, ied.pos, -1);
@@ -3058,7 +3058,7 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
expirey = ies->refresh;
if (ies->dpstatus & IAX_DPSTATUS_MATCHMORE)
matchmore = CACHE_FLAG_MATCHMORE;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
prev = NULL;
dp = pvt->dpentries;
while(dp) {
@@ -3084,7 +3084,7 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
prev = dp;
dp = dp->peer;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
return 0;
}
@@ -3123,7 +3123,7 @@ static int complete_transfer(int callno, struct iax_ies *ies)
pvt->last = 0;
pvt->lastsent = 0;
pvt->pingtime = DEFAULT_RETRY_TIME;
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
for (cur = iaxq.head; cur ; cur = cur->next) {
/* We must cancel any packets that would have been transmitted
because now we're talking to someone new. It's okay, they
@@ -3131,7 +3131,7 @@ static int complete_transfer(int callno, struct iax_ies *ies)
if (callno == cur->callno)
cur->retries = -1;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
return 0;
}
@@ -3395,14 +3395,14 @@ static int auto_hangup(void *nothing)
/* Called from IAX thread only, without iaxs lock */
int callno = (int)(long)(nothing);
struct iax_ie_data ied;
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
iaxs[callno]->autoid = -1;
memset(&ied, 0, sizeof(ied));
iax_ie_append_str(&ied, IAX_IE_CAUSE, "Timeout");
send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1);
}
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
@@ -3427,7 +3427,7 @@ static int iax2_vnak(int callno)
static void vnak_retransmit(int callno, int last)
{
struct iax_frame *f;
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
f = iaxq.head;
while(f) {
/* Send a copy immediately */
@@ -3437,7 +3437,7 @@ static void vnak_retransmit(int callno, int last)
}
f = f->next;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
}
static int iax2_poke_peer_s(void *data)
@@ -3472,7 +3472,7 @@ static int send_trunk(struct iax2_peer *peer)
/* Search through trunked calls for a match with this peer */
for (x=TRUNK_CALL_START;x<maxtrunkcall; x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
#if 0
if (iaxtrunkdebug)
ast_verbose("Call %d is at %s:%d (%d)\n", x, inet_ntoa(iaxs[x]->addr.sin_addr), ntohs(iaxs[x]->addr.sin_port), iaxs[x]->addr.sin_family);
@@ -3500,7 +3500,7 @@ static int send_trunk(struct iax2_peer *peer)
if (!firstcall)
firstcall = x;
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
if (calls) {
/* We're actually sending a frame, so fill the meta trunk header and meta header */
@@ -3548,12 +3548,12 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
res = read(fd, buf, sizeof(buf));
if (res < 1) {
ast_log(LOG_WARNING, "Unable to read from timing fd\n");
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return 1;
}
}
/* For each peer that supports trunking... */
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (peer->trunk) {
@@ -3566,7 +3566,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (iaxtrunkdebug)
ast_verbose("Ending trunk processing with %d peers and %d calls processed\n", processed, totalcalls);
iaxtrunkdebug =0;
@@ -3634,14 +3634,14 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
ts = ntohl(mth->ts);
res -= (sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr));
ptr = mth->data;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!inaddrcmp(&peer->addr, &sin))
break;
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!peer) {
ast_log(LOG_WARNING, "Unable to accept trunked packet from '%s:%d': No matching peer\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
return 1;
@@ -3660,7 +3660,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
break;
fr.callno = find_callno(ntohs(mte->callno) & ~IAX_FLAG_FULL, 0, &sin, NEW_PREVENT, 1);
if (fr.callno) {
- ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+ ast_mutex_lock(&iaxsl[fr.callno]);
/* If it's a valid call, deliver the contents. If not, we
drop it, since we don't have a scallno to use for an INVAL */
/* Process as a mini frame */
@@ -3703,7 +3703,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
ast_log(LOG_WARNING, "Received trunked frame before first full voice frame\n ");
iax2_vnak(fr.callno);
}
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
}
ptr += len;
res -= len;
@@ -3739,7 +3739,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
fr.callno = find_callno(ntohs(mh->callno) & ~IAX_FLAG_FULL, dcallno, &sin, new, 1);
if (fr.callno > 0)
- ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+ ast_mutex_lock(&iaxsl[fr.callno]);
if (!fr.callno || !iaxs[fr.callno]) {
/* A call arrived for a non-existant destination. Unless it's an "inval"
@@ -3754,7 +3754,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
);
}
if (fr.callno > 0)
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
if (!inaddrcmp(&sin, &iaxs[fr.callno]->addr) && !minivid)
@@ -3798,7 +3798,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
/* Send a VNAK requesting retransmission */
iax2_vnak(fr.callno);
}
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
} else {
@@ -3814,7 +3814,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
/* A full frame */
if (res < sizeof(struct ast_iax2_full_hdr)) {
ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, sizeof(struct ast_iax2_full_hdr));
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
f.datalen = res - sizeof(struct ast_iax2_full_hdr);
@@ -3838,7 +3838,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
/* Ack the packet with the given timestamp */
if (option_debug)
ast_log(LOG_DEBUG, "Cancelling transmission of packet %d\n", x);
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
for (cur = iaxq.head; cur ; cur = cur->next) {
/* If it's our call, and our timestamp, mark -1 retries */
if ((fr.callno == cur->callno) && (x == cur->oseqno)) {
@@ -3851,14 +3851,14 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
}
}
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
}
/* Note how much we've received acknowledgement for */
if (iaxs[fr.callno])
iaxs[fr.callno]->rseqno = fr.iseqno;
else {
/* Stop processing now */
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
} else
@@ -3869,7 +3869,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
((f.subclass != IAX_COMMAND_TXACC) &&
(f.subclass != IAX_COMMAND_TXCNT)))) {
/* Only messages we accept from a transfer host are TXACC and TXCNT */
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
@@ -3877,7 +3877,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
if (f.frametype == AST_FRAME_IAX) {
if (iax_parse_ies(&ies, buf + sizeof(struct ast_iax2_full_hdr), f.datalen)) {
ast_log(LOG_WARNING, "undecodable frame received\n");
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
f.data = NULL;
@@ -3897,10 +3897,10 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
if (iaxs[fr.callno]->owner) {
int orignative;
retryowner:
- if (pthread_mutex_trylock(&iaxs[fr.callno]->owner->lock)) {
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ if (ast_mutex_trylock(&iaxs[fr.callno]->owner->lock)) {
+ ast_mutex_unlock(&iaxsl[fr.callno]);
usleep(1);
- ast_pthread_mutex_lock(&iaxsl[fr.callno]);
+ ast_mutex_lock(&iaxsl[fr.callno]);
if (iaxs[fr.callno] && iaxs[fr.callno]->owner) goto retryowner;
}
if (iaxs[fr.callno]) {
@@ -3910,11 +3910,11 @@ retryowner:
if (iaxs[fr.callno]->owner->readformat)
ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
iaxs[fr.callno]->owner->nativeformats = orignative;
- ast_pthread_mutex_unlock(&iaxs[fr.callno]->owner->lock);
+ ast_mutex_unlock(&iaxs[fr.callno]->owner->lock);
}
} else {
ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
}
@@ -3954,13 +3954,13 @@ retryowner:
case IAX_COMMAND_TXACC:
if (iaxs[fr.callno]->transferring == TRANSFER_BEGIN) {
/* Ack the packet with the given timestamp */
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
for (cur = iaxq.head; cur ; cur = cur->next) {
/* Cancel any outstanding txcnt's */
if ((fr.callno == cur->callno) && (cur->transfer))
cur->retries = -1;
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
memset(&ied1, 0, sizeof(ied1));
iax_ie_append_short(&ied1, IAX_IE_CALLNO, iaxs[fr.callno]->callno);
send_command(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_TXREADY, 0, ied1.buf, ied1.pos, -1);
@@ -4125,7 +4125,7 @@ retryowner:
ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
}
}
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = iaxs[fr.callno]->dpentries;
while(dp) {
if (!(dp->flags & CACHE_FLAG_TRANSMITTED)) {
@@ -4133,7 +4133,7 @@ retryowner:
}
dp = dp->peer;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
break;
case IAX_COMMAND_POKE:
/* Send back a pong packet with the original timestamp */
@@ -4430,7 +4430,7 @@ retryowner:
if (iaxs[fr.callno] && iaxs[fr.callno]->aseqno != iaxs[fr.callno]->iseqno)
send_command_immediate(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr.ts, NULL, 0,fr.iseqno);
}
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
/* Unless this is an ACK or INVAL frame, ack it */
@@ -4443,7 +4443,7 @@ retryowner:
else {
ast_log(LOG_WARNING, "Received mini frame before first full voice frame\n ");
iax2_vnak(fr.callno);
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
f.datalen = res - sizeof(struct ast_iax2_video_hdr);
@@ -4460,13 +4460,13 @@ retryowner:
else {
ast_log(LOG_WARNING, "Received mini frame before first full voice frame\n ");
iax2_vnak(fr.callno);
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
f.datalen = res - sizeof(struct ast_iax2_mini_hdr);
if (f.datalen < 0) {
ast_log(LOG_WARNING, "Datalen < 0?\n");
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
if (f.datalen)
@@ -4477,7 +4477,7 @@ retryowner:
}
/* Don't pass any packets until we're started */
if (!(iaxs[fr.callno]->state & IAX_STATE_STARTED)) {
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
/* Common things */
@@ -4509,7 +4509,7 @@ retryowner:
schedule_delivery(iaxfrdup2(&fr), 1, updatehistory);
#endif
/* Always run again */
- ast_pthread_mutex_unlock(&iaxsl[fr.callno]);
+ ast_mutex_unlock(&iaxsl[fr.callno]);
return 1;
}
@@ -4632,7 +4632,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data)
ast_log(LOG_WARNING, "Unable to create call\n");
return NULL;
}
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
/* If this is a trunk, update it now */
iaxs[callno]->trunk = trunk;
if (trunk)
@@ -4642,7 +4642,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data)
iaxs[callno]->maxtime = maxtime;
iaxs[callno]->notransfer = notransfer;
c = ast_iax2_new(iaxs[callno], AST_STATE_DOWN, capability);
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
if (c) {
/* Choose a format we can live with */
if (c->nativeformats & format)
@@ -4675,7 +4675,7 @@ static void *network_thread(void *ignore)
for(;;) {
/* Go through the queue, sending messages which have not yet been
sent, and scheduling retransmissions if appropriate */
- ast_pthread_mutex_lock(&iaxq.lock);
+ ast_mutex_lock(&iaxq.lock);
f = iaxq.head;
while(f) {
freeme = NULL;
@@ -4708,7 +4708,7 @@ static void *network_thread(void *ignore)
if (freeme)
iax_frame_free(freeme);
}
- ast_pthread_mutex_unlock(&iaxq.lock);
+ ast_mutex_unlock(&iaxq.lock);
res = ast_sched_wait(sched);
if ((res > 1000) || (res < 0))
res = 1000;
@@ -4755,7 +4755,7 @@ static struct iax2_peer *build_peer(char *name, struct ast_variable *v)
int format;
int found=0;
prev = NULL;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!strcasecmp(peer->name, name)) {
@@ -4772,9 +4772,9 @@ static struct iax2_peer *build_peer(char *name, struct ast_variable *v)
} else {
peerl.peers = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
} else {
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
peer = malloc(sizeof(struct iax2_peer));
memset(peer, 0, sizeof(struct iax2_peer));
peer->expire = -1;
@@ -4967,7 +4967,7 @@ static void delete_users(void){
struct iax2_registry *reg, *regl;
/* Delete all users */
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
for (user=userl.users;user;) {
ast_free_ha(user->ha);
free_context(user->contexts);
@@ -4976,7 +4976,7 @@ static void delete_users(void){
free(userlast);
}
userl.users=NULL;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
for (reg = registrations;reg;) {
regl = reg;
@@ -4986,30 +4986,30 @@ static void delete_users(void){
free(regl);
}
registrations = NULL;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer=peerl.peers;peer;) {
/* Assume all will be deleted, and we'll find out for sure later */
peer->delme = 1;
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
static void prune_peers(void){
/* Prune peers who still are supposed to be deleted */
struct iax2_peer *peer, *peerlast, *peernext;
int x;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peerlast = NULL;
for (peer=peerl.peers;peer;) {
peernext = peer->next;
if (peer->delme) {
for (x=0;x<IAX_MAX_CALLS;x++) {
- ast_pthread_mutex_lock(&iaxsl[x]);
+ ast_mutex_lock(&iaxsl[x]);
if (iaxs[x] && (iaxs[x]->peerpoke == peer)) {
iax2_destroy(x);
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
/* Delete it, it needs to disappear */
if (peer->expire > -1)
@@ -5027,7 +5027,7 @@ static void prune_peers(void){
peerlast = peer;
peer=peernext;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
static void set_timing(void)
@@ -5157,19 +5157,19 @@ static int set_config(char *config_file, struct sockaddr_in* sin){
if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
user = build_user(cat, ast_variable_browse(cfg, cat));
if (user) {
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user->next = userl.users;
userl.users = user;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
}
}
if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
peer = build_peer(cat, ast_variable_browse(cfg, cat));
if (peer) {
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer->next = peerl.peers;
peerl.peers = peer;
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
} else if (strcasecmp(utype, "user")) {
ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, config_file);
@@ -5220,12 +5220,12 @@ static int cache_get_callno(char *data)
for (x=0;x<IAX_MAX_CALLS; x++) {
/* Look for an *exact match* call. Once a call is negotiated, it can only
look up entries for a single context */
- if (!pthread_mutex_trylock(&iaxsl[x])) {
+ if (!ast_mutex_trylock(&iaxsl[x])) {
if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot)) {
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
return x;
}
- ast_pthread_mutex_unlock(&iaxsl[x]);
+ ast_mutex_unlock(&iaxsl[x]);
}
}
memset(&ied, 0, sizeof(ied));
@@ -5264,7 +5264,7 @@ static int cache_get_callno(char *data)
ast_log(LOG_WARNING, "Unable to create call\n");
return -1;
}
- ast_pthread_mutex_lock(&iaxsl[callno]);
+ ast_mutex_lock(&iaxsl[callno]);
strncpy(iaxs[callno]->dproot, data, sizeof(iaxs[callno]->dproot)-1);
iaxs[callno]->capability = IAX_CAPABILITY_FULLBANDWIDTH;
@@ -5286,7 +5286,7 @@ static int cache_get_callno(char *data)
#endif
/* Start the call going */
send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_NEW, 0, ied.buf, ied.pos, -1);
- ast_pthread_mutex_unlock(&iaxsl[callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
return callno;
}
@@ -5380,7 +5380,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, char *data, cha
/* Okay, now we wait */
timeout = iaxdefaulttimeout * 1000;
/* Temporarily unlock */
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
/* Defer any dtmf */
if (chan)
old = ast_channel_defer_dtmf(chan);
@@ -5404,7 +5404,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, char *data, cha
if (!timeout) {
ast_log(LOG_WARNING, "Timeout waiting for %s exten %s\n", data, exten);
}
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp->waiters[x] = -1;
close(com[1]);
close(com[0]);
@@ -5446,13 +5446,13 @@ static int iax2_exists(struct ast_channel *chan, char *context, char *exten, int
#endif
if (priority != 1)
return 0;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_EXISTS)
res= 1;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
if (!dp) {
ast_log(LOG_WARNING, "Unable to make DP cache\n");
}
@@ -5468,13 +5468,13 @@ static int iax2_canmatch(struct ast_channel *chan, char *context, char *exten, i
#endif
if (priority != 1)
return 0;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_CANEXIST)
res= 1;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
if (!dp) {
ast_log(LOG_WARNING, "Unable to make DP cache\n");
}
@@ -5490,13 +5490,13 @@ static int iax2_matchmore(struct ast_channel *chan, char *context, char *exten,
#endif
if (priority != 1)
return 0;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_MATCHMORE)
res= 1;
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
if (!dp) {
ast_log(LOG_WARNING, "Unable to make DP cache\n");
}
@@ -5515,7 +5515,7 @@ static int iax2_exec(struct ast_channel *chan, char *context, char *exten, int p
#endif
if (priority != 1)
return -1;
- ast_pthread_mutex_lock(&dpcache_lock);
+ ast_mutex_lock(&dpcache_lock);
dp = find_cache(chan, data, context, exten, priority);
if (dp) {
if (dp->flags & CACHE_FLAG_EXISTS) {
@@ -5531,12 +5531,12 @@ static int iax2_exec(struct ast_channel *chan, char *context, char *exten, int p
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Executing Dial('%s')\n", req);
} else {
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
ast_log(LOG_WARNING, "Can't execute non-existant extension '%s[@%s]' in data '%s'\n", exten, context, data);
return -1;
}
}
- ast_pthread_mutex_unlock(&dpcache_lock);
+ ast_mutex_unlock(&dpcache_lock);
dial = pbx_findapp("Dial");
if (dial) {
pbx_exec(chan, dial, req, newstack);
@@ -5587,7 +5587,7 @@ int load_module(void)
#endif
for (x=0;x<IAX_MAX_CALLS;x++)
- ast_pthread_mutex_init(&iaxsl[x]);
+ ast_mutex_init(&iaxsl[x]);
io = io_context_create();
sched = sched_context_create();
@@ -5597,9 +5597,9 @@ int load_module(void)
return -1;
}
- ast_pthread_mutex_init(&iaxq.lock);
- ast_pthread_mutex_init(&userl.lock);
- ast_pthread_mutex_init(&peerl.lock);
+ ast_mutex_init(&iaxq.lock);
+ ast_mutex_init(&userl.lock);
+ ast_mutex_init(&peerl.lock);
ast_cli_register(&cli_show_users);
ast_cli_register(&cli_show_channels);
@@ -5653,10 +5653,10 @@ int load_module(void)
}
for (reg = registrations; reg; reg = reg->next)
iax2_do_register(reg);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer = peerl.peers; peer; peer = peer->next)
iax2_poke_peer(peer);
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return res;
}
@@ -5690,9 +5690,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;
}
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 662cf7c0c..7889d0fa3 100755
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -49,15 +49,15 @@ static char *tdesc = "Local Proxy Channel Driver";
static int capability = -1;
static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
#define IS_OUTBOUND(a,b) (a == b->chan ? 1 : 0)
/* Protect the interface list (of sip_pvt's) */
-static pthread_mutex_t locallock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t locallock = AST_MUTEX_INITIALIZER;
static struct local_pvt {
- pthread_mutex_t lock; /* Channel private lock */
+ ast_mutex_t lock; /* Channel private lock */
char context[AST_MAX_EXTENSION]; /* Context to call */
char exten[AST_MAX_EXTENSION]; /* Extension to call */
int reqformat; /* Requested format */
@@ -84,25 +84,25 @@ retrylock:
if (p->cancelqueue) {
/* We had a glare on the hangup. Forget all this business,
return and destroy p. */
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
free(p);
return -1;
}
- if (pthread_mutex_trylock(&other->lock)) {
+ if (ast_mutex_trylock(&other->lock)) {
/* Failed to lock. Release main lock and try again */
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
if (us)
- ast_pthread_mutex_unlock(&us->lock);
+ ast_mutex_unlock(&us->lock);
/* Wait just a bit */
usleep(1);
/* Only we can destroy ourselves, so we can't disappear here */
if (us)
- ast_pthread_mutex_lock(&us->lock);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&us->lock);
+ ast_mutex_lock(&p->lock);
goto retrylock;
}
ast_queue_frame(other, f, 0);
- ast_pthread_mutex_unlock(&other->lock);
+ ast_mutex_unlock(&other->lock);
p->glaredetect = 0;
return 0;
}
@@ -112,14 +112,14 @@ static int local_answer(struct ast_channel *ast)
struct local_pvt *p = ast->pvt->pvt;
int isoutbound = IS_OUTBOUND(ast, p);
int res = -1;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (isoutbound) {
/* Pass along answer since somebody answered us */
struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
res = local_queue_frame(p, isoutbound, &answer, ast);
} else
ast_log(LOG_WARNING, "Huh? Local is being asked to answer?\n");
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -130,19 +130,19 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
if (isoutbound && p->chan && p->chan->bridge && p->owner) {
/* Masquerade bridged channel into owner */
/* Lock other side first */
- ast_pthread_mutex_lock(&p->chan->bridge->lock);
- ast_pthread_mutex_lock(&p->owner->lock);
+ ast_mutex_lock(&p->chan->bridge->lock);
+ ast_mutex_lock(&p->owner->lock);
ast_channel_masquerade(p->owner, p->chan->bridge);
- ast_pthread_mutex_unlock(&p->owner->lock);
- ast_pthread_mutex_unlock(&p->chan->bridge->lock);
+ ast_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->chan->bridge->lock);
p->alreadymasqed = 1;
} else if (!isoutbound && p->owner && p->owner->bridge && p->chan) {
/* Masquerade bridged channel into chan */
- ast_pthread_mutex_lock(&p->owner->bridge->lock);
- ast_pthread_mutex_lock(&p->chan->lock);
+ ast_mutex_lock(&p->owner->bridge->lock);
+ ast_mutex_lock(&p->chan->lock);
ast_channel_masquerade(p->chan, p->owner->bridge);
- ast_pthread_mutex_unlock(&p->chan->lock);
- ast_pthread_mutex_unlock(&p->owner->bridge->lock);
+ ast_mutex_unlock(&p->chan->lock);
+ ast_mutex_unlock(&p->owner->bridge->lock);
p->alreadymasqed = 1;
}
}
@@ -161,27 +161,27 @@ static int local_write(struct ast_channel *ast, struct ast_frame *f)
/* Just queue for delivery to the other side */
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
res = local_queue_frame(p, isoutbound, f, ast);
check_bridge(p, isoutbound);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
struct local_pvt *p = newchan->pvt->pvt;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if ((p->owner != oldchan) && (p->chan != oldchan)) {
ast_log(LOG_WARNING, "old channel wasn't %p but was %p/%p\n", oldchan, p->owner, p->chan);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return -1;
}
if (p->owner == oldchan)
p->owner = newchan;
else
p->chan = newchan;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
@@ -192,10 +192,10 @@ static int local_indicate(struct ast_channel *ast, int condition)
struct ast_frame f = { AST_FRAME_CONTROL, };
int isoutbound = IS_OUTBOUND(ast, p);
/* Queue up a frame representing the indication as a control frame */
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
f.subclass = condition;
res = local_queue_frame(p, isoutbound, &f, ast);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -205,10 +205,10 @@ static int local_digit(struct ast_channel *ast, char digit)
int res = -1;
struct ast_frame f = { AST_FRAME_DTMF, };
int isoutbound = IS_OUTBOUND(ast, p);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
f.subclass = digit;
res = local_queue_frame(p, isoutbound, &f, ast);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -231,7 +231,7 @@ static int local_call(struct ast_channel *ast, char *dest, int timeout)
static void local_destroy(struct local_pvt *p)
{
struct local_pvt *cur, *prev = NULL;
- ast_pthread_mutex_lock(&locallock);
+ ast_mutex_lock(&locallock);
cur = locals;
while(cur) {
if (cur == p) {
@@ -245,7 +245,7 @@ static void local_destroy(struct local_pvt *p)
prev = cur;
cur = cur->next;
}
- ast_pthread_mutex_unlock(&locallock);
+ ast_mutex_unlock(&locallock);
if (!cur)
ast_log(LOG_WARNING, "Unable ot find local '%s@%s' in local list\n", p->exten, p->context);
}
@@ -258,7 +258,7 @@ static int local_hangup(struct ast_channel *ast)
struct local_pvt *cur, *prev=NULL;
struct ast_channel *ochan = NULL;
int glaredetect;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (isoutbound)
p->chan = NULL;
else
@@ -272,9 +272,9 @@ static int local_hangup(struct ast_channel *ast)
let local_queue do it. */
if (p->glaredetect)
p->cancelqueue = 1;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Remove from list */
- ast_pthread_mutex_lock(&locallock);
+ ast_mutex_lock(&locallock);
cur = locals;
while(cur) {
if (cur == p) {
@@ -287,7 +287,7 @@ static int local_hangup(struct ast_channel *ast)
prev = cur;
cur = cur->next;
}
- ast_pthread_mutex_unlock(&locallock);
+ ast_mutex_unlock(&locallock);
/* And destroy */
if (!glaredetect)
free(p);
@@ -298,7 +298,7 @@ static int local_hangup(struct ast_channel *ast)
ochan = p->chan;
else
local_queue_frame(p, isoutbound, &f, NULL);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
if (ochan)
ast_hangup(ochan);
return 0;
@@ -311,7 +311,7 @@ static struct local_pvt *local_alloc(char *data, int format)
tmp = malloc(sizeof(struct local_pvt));
if (tmp) {
memset(tmp, 0, sizeof(struct local_pvt));
- ast_pthread_mutex_init(&tmp->lock);
+ ast_mutex_init(&tmp->lock);
strncpy(tmp->exten, data, sizeof(tmp->exten) - 1);
c = strchr(tmp->exten, '@');
if (c) {
@@ -327,10 +327,10 @@ static struct local_pvt *local_alloc(char *data, int format)
tmp = NULL;
} else {
/* Add to list */
- ast_pthread_mutex_lock(&locallock);
+ ast_mutex_lock(&locallock);
tmp->next = locals;
locals = tmp;
- ast_pthread_mutex_unlock(&locallock);
+ ast_mutex_unlock(&locallock);
}
}
@@ -389,9 +389,9 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
tmp2->pvt->fixup = local_fixup;
p->owner = tmp;
p->chan = tmp2;
- 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, p->context, sizeof(tmp->context)-1);
strncpy(tmp2->context, p->context, sizeof(tmp2->context)-1);
@@ -420,17 +420,17 @@ static int locals_show(int fd, int argc, char **argv)
if (argc != 2)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&locallock);
+ ast_mutex_lock(&locallock);
p = locals;
while(p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
ast_cli(fd, "%s -- %s@%s\n", p->owner ? p->owner->name : "<unowned>", p->exten, p->context);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
p = p->next;
}
if (!locals)
ast_cli(fd, "No local channels in use\n");
- ast_pthread_mutex_unlock(&locallock);
+ ast_mutex_unlock(&locallock);
return RESULT_SUCCESS;
}
@@ -464,7 +464,7 @@ int unload_module()
/* First, take us out of the channel loop */
ast_cli_unregister(&cli_show_locals);
ast_channel_unregister(type);
- if (!ast_pthread_mutex_lock(&locallock)) {
+ if (!ast_mutex_lock(&locallock)) {
/* Hangup all interfaces if they have an owner */
p = locals;
while(p) {
@@ -473,7 +473,7 @@ int unload_module()
p = p->next;
}
locals = NULL;
- ast_pthread_mutex_unlock(&locallock);
+ ast_mutex_unlock(&locallock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
return -1;
@@ -484,9 +484,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;
}
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 691483ea8..19045e85b 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -142,7 +142,7 @@ static int adsi = 0;
static int usecnt =0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static int oseq;
/* Wait up to 16 seconds for first digit (FXO logic) */
@@ -156,9 +156,9 @@ static int matchdigittimeout = 3000;
/* 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 netlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t netlock = AST_MUTEX_INITIALIZER;
-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. */
@@ -219,7 +219,7 @@ struct mgcp_message {
#define SUB_ALT 1
struct mgcp_subchannel {
- pthread_mutex_t lock;
+ ast_mutex_t lock;
int id;
struct ast_channel *owner;
struct mgcp_endpoint *parent;
@@ -247,7 +247,7 @@ struct mgcp_subchannel {
#define TYPE_LINE 2
struct mgcp_endpoint {
- pthread_mutex_t lock;
+ ast_mutex_t lock;
char name[80];
struct mgcp_subchannel *sub; /* pointer to our current connection, channel and stuff */
char accountcode[80];
@@ -307,7 +307,7 @@ static struct mgcp_gateway {
struct mgcp_gateway *next;
} *gateways;
-static pthread_mutex_t gatelock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t gatelock = AST_MUTEX_INITIALIZER;
static int mgcpsock = -1;
@@ -526,7 +526,7 @@ static int mgcp_hangup(struct ast_channel *ast)
if ((p->dtmfinband) && (p->dsp != NULL)){
ast_dsp_free(p->dsp);
}
- ast_pthread_mutex_lock(&sub->lock);
+ ast_mutex_lock(&sub->lock);
sub->owner = NULL;
if (strlen(sub->cxident)) {
@@ -581,7 +581,7 @@ static int mgcp_hangup(struct ast_channel *ast)
transmit_notify_request(sub, "vmwi(-)");
}
}
- ast_pthread_mutex_unlock(&sub->lock);
+ ast_mutex_unlock(&sub->lock);
return 0;
}
@@ -592,7 +592,7 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
int hasendpoints = 0;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&gatelock);
+ ast_mutex_lock(&gatelock);
g = gateways;
while(g) {
e = g->endpoints;
@@ -607,7 +607,7 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
}
g = g->next;
}
- ast_pthread_mutex_unlock(&gatelock);
+ ast_mutex_unlock(&gatelock);
return RESULT_SUCCESS;
}
@@ -644,7 +644,7 @@ static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
gname++;
if ((c = strrchr(gname, ']')))
*c = '\0';
- ast_pthread_mutex_lock(&gatelock);
+ ast_mutex_lock(&gatelock);
g = gateways;
while(g) {
if (!strcasecmp(g->name, gname)) {
@@ -666,7 +666,7 @@ static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
if (!found) {
ast_cli(fd, " << Could not find endpoint >> ");
}
- ast_pthread_mutex_unlock(&gatelock);
+ ast_mutex_unlock(&gatelock);
return RESULT_SUCCESS;
}
@@ -731,9 +731,9 @@ static struct ast_frame *mgcp_read(struct ast_channel *ast)
{
struct ast_frame *fr;
struct mgcp_subchannel *sub = ast->pvt->pvt;
- ast_pthread_mutex_lock(&sub->lock);
+ ast_mutex_lock(&sub->lock);
fr = mgcp_rtp_read(sub);
- ast_pthread_mutex_unlock(&sub->lock);
+ ast_mutex_unlock(&sub->lock);
return fr;
}
@@ -756,11 +756,11 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
}
}
if (sub) {
- ast_pthread_mutex_lock(&sub->lock);
+ ast_mutex_lock(&sub->lock);
if (sub->rtp) {
res = ast_rtp_write(sub->rtp, frame);
}
- ast_pthread_mutex_unlock(&sub->lock);
+ ast_mutex_unlock(&sub->lock);
}
return res;
}
@@ -892,9 +892,9 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
if (i->amaflags)
tmp->amaflags = i->amaflags;
sub->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();
tmp->callgroup = i->callgroup;
tmp->pickupgroup = i->pickupgroup;
@@ -987,13 +987,13 @@ static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
{
/* Just deliver the audio directly */
struct mgcp_endpoint *p = data;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->owner) {
/* Generally, you lock in the order channel lock, followed by private
lock. Since here we are doing the reverse, there is the possibility
of deadlock. As a result, in the case of a deadlock, we simply fail out
here. */
- if (!pthread_mutex_trylock(&p->owner->lock)) {
+ if (!ast_mutex_trylock(&p->owner->lock)) {
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != p->owner->nativeformats) {
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
@@ -1006,10 +1006,10 @@ static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
}
}
ast_queue_frame(p->owner, f, 0);
- pthread_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->owner->lock);
}
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
#endif
@@ -1032,7 +1032,7 @@ static struct mgcp_subchannel *find_subchannel(char *name, int msgid, struct soc
*at = '\0';
at++;
}
- ast_pthread_mutex_lock(&gatelock);
+ ast_mutex_lock(&gatelock);
if (at && (at[0] == '[')) {
at++;
c = strrchr(at, ']');
@@ -1086,7 +1086,7 @@ static struct mgcp_subchannel *find_subchannel(char *name, int msgid, struct soc
}
g = g->next;
}
- ast_pthread_mutex_unlock(&gatelock);
+ ast_mutex_unlock(&gatelock);
if (!sub) {
if (name) {
if (g)
@@ -1724,7 +1724,7 @@ static void handle_response(struct mgcp_subchannel *sub, int result, int ident)
static void start_rtp(struct mgcp_subchannel *sub)
{
- ast_pthread_mutex_lock(&sub->lock);
+ ast_mutex_lock(&sub->lock);
/* Allocate the RTP now */
sub->rtp = ast_rtp_new(sched, io, 1, 0);
if (sub->rtp && sub->owner)
@@ -1739,7 +1739,7 @@ static void start_rtp(struct mgcp_subchannel *sub)
snprintf(sub->callid, sizeof(sub->callid), "%08x%s", rand(), sub->txident);
/* Transmit the connection create */
transmit_connect_with_sdp(sub, NULL);
- ast_pthread_mutex_unlock(&sub->lock);
+ ast_mutex_unlock(&sub->lock);
}
static void *mgcp_ss(void *data)
@@ -2479,9 +2479,9 @@ static void *do_monitor(void *data)
/* Check for interfaces needing to be killed */
/* 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. */
- ast_pthread_mutex_lock(&monlock);
+ ast_mutex_lock(&monlock);
/* Lock the network interface */
- ast_pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
p = packets;
while(p) {
/* Handle any retransmissions */
@@ -2519,17 +2519,17 @@ static void *do_monitor(void *data)
#endif
/* Okay, now that we know what to do, release the network lock */
- ast_pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
/* 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 for sched or io */
res = ast_sched_wait(sched);
res = ast_io_wait(io, res);
- ast_pthread_mutex_lock(&monlock);
+ ast_mutex_lock(&monlock);
if (res >= 0)
ast_sched_runq(sched);
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
}
/* Never reached */
return NULL;
@@ -2541,12 +2541,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;
}
@@ -2556,12 +2556,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;
}
@@ -2932,10 +2932,10 @@ int load_module()
if (option_verbose > 2) {
ast_verbose(VERBOSE_PREFIX_3 "Added gateway '%s'\n", g->name);
}
- ast_pthread_mutex_lock(&gatelock);
+ ast_mutex_lock(&gatelock);
g->next = gateways;
gateways = g;
- ast_pthread_mutex_unlock(&gatelock);
+ ast_mutex_unlock(&gatelock);
}
}
cat = ast_category_browse(cfg, cat);
@@ -2954,7 +2954,7 @@ int load_module()
if (!ntohs(bindaddr.sin_port))
bindaddr.sin_port = ntohs(DEFAULT_MGCP_PORT);
bindaddr.sin_family = AF_INET;
- pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
if (mgcpsock > -1)
close(mgcpsock);
mgcpsock = socket(AF_INET, SOCK_DGRAM, 0);
@@ -2977,7 +2977,7 @@ int load_module()
ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
}
}
- pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
ast_destroy(cfg);
/* Make sure we can register our mgcp channel type */
@@ -3015,7 +3015,7 @@ int unload_module()
struct mgcp_endpoint *p, *pl;
/* First, take us out of the channel loop */
ast_channel_unregister(type);
- if (!ast_pthread_mutex_lock(&gatelock)) {
+ if (!ast_mutex_lock(&gatelock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
@@ -3024,25 +3024,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) {
@@ -3052,7 +3052,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;
@@ -3064,9 +3064,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;
}
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index 900eb0ad5..b62002679 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -71,14 +71,14 @@ static int baudrate = 115200;
static int stripmsd = 0;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of ast_modem_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. */
@@ -421,11 +421,11 @@ static int modem_hangup(struct ast_channel *ast)
memset(p->cid, 0, sizeof(p->cid));
memset(p->dnid, 0, sizeof(p->dnid));
((struct ast_modem_pvt *)(ast->pvt->pvt))->owner = NULL;
- 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);
@@ -525,9 +525,9 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
if (strlen(i->dnid))
strncpy(tmp->exten, i->dnid, sizeof(tmp->exten) - 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();
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
@@ -570,14 +570,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
@@ -600,10 +600,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);
#if 0
ast_log(LOG_DEBUG, "In monitor, n=%d, pid=%d\n", n, getpid());
#endif
@@ -618,7 +618,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;
}
@@ -634,7 +634,7 @@ static void *do_monitor(void *data)
}
i=i->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
}
/* Never reached */
return NULL;
@@ -646,12 +646,12 @@ static int restart_monitor()
/* 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;
}
@@ -663,11 +663,11 @@ static int restart_monitor()
}
/* 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;
}
@@ -762,7 +762,7 @@ static struct ast_channel *modem_request(char *type, int format, void *data)
}
/* 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;
}
@@ -799,7 +799,7 @@ static struct ast_channel *modem_request(char *type, int format, void *data)
if (!p)
ast_log(LOG_WARNING, "Requested device '%s' does not exist\n", dev);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return tmp;
}
@@ -852,7 +852,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;
@@ -869,7 +869,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;
}
@@ -881,7 +881,7 @@ int load_module()
if (ast_load_resource(driver)) {
ast_log(LOG_ERROR, "Failed to load driver %s\n", driver);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
@@ -915,7 +915,7 @@ int load_module()
}
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */
AST_FORMAT_SLINEAR, modem_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -934,7 +934,7 @@ int unload_module()
struct ast_modem_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) {
@@ -943,24 +943,24 @@ 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 > -1) {
pthread_cancel(monitor_thread);
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) {
@@ -973,7 +973,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;
@@ -985,9 +985,9 @@ int unload_module()
int usecount(void)
{
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;
}
diff --git a/channels/chan_modem_aopen.c b/channels/chan_modem_aopen.c
index 3aa1978af..4222e85cd 100755
--- a/channels/chan_modem_aopen.c
+++ b/channels/chan_modem_aopen.c
@@ -34,7 +34,7 @@ static char *breakcmd = "\0x10\0x03";
static char *desc = "A/Open (Rockwell Chipset) ITU-2 VoiceModem Driver";
static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *aopen_idents[] = {
/* Identify A/Open Modem */
@@ -363,17 +363,17 @@ static char *aopen_identify(struct ast_modem_pvt *p)
static void aopen_incusecnt(void)
{
- 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();
}
static void aopen_decusecnt(void)
{
- 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();
}
@@ -457,9 +457,9 @@ static struct ast_modem_driver aopen_driver =
int usecount(void)
{
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;
}
diff --git a/channels/chan_modem_bestdata.c b/channels/chan_modem_bestdata.c
index 90cc87828..10732dca7 100755
--- a/channels/chan_modem_bestdata.c
+++ b/channels/chan_modem_bestdata.c
@@ -39,7 +39,7 @@ static char *breakcmd = "\020!";
static char *desc = "BestData (Conexant V.90 Chipset) VoiceModem Driver";
static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *bestdata_idents[] = {
/* Identify BestData Modem */
@@ -439,17 +439,17 @@ static char *bestdata_identify(struct ast_modem_pvt *p)
static void bestdata_incusecnt(void)
{
- 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();
}
static void bestdata_decusecnt(void)
{
- 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();
}
@@ -570,9 +570,9 @@ static struct ast_modem_driver bestdata_driver =
int usecount(void)
{
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;
}
diff --git a/channels/chan_modem_i4l.c b/channels/chan_modem_i4l.c
index 857188277..c011a9fc8 100755
--- a/channels/chan_modem_i4l.c
+++ b/channels/chan_modem_i4l.c
@@ -34,7 +34,7 @@ static char *breakcmd = "\0x10\0x14\0x10\0x3";
static char *desc = "ISDN4Linux Emulated Modem Driver";
static int usecnt;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *i4l_idents[] = {
/* Identify ISDN4Linux Driver */
@@ -476,17 +476,17 @@ static char *i4l_identify(struct ast_modem_pvt *p)
static void i4l_incusecnt(void)
{
- 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();
}
static void i4l_decusecnt(void)
{
- 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();
}
@@ -597,9 +597,9 @@ static struct ast_modem_driver i4l_driver =
int usecount(void)
{
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;
}
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index f366f976e..0cf50f56c 100755
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -41,7 +41,7 @@ static int usecnt =0;
/* Only linear is allowed */
static int prefformat = AST_FORMAT_SLINEAR;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char context[AST_MAX_EXTENSION] = "default";
@@ -215,9 +215,9 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state)
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
strcpy(tmp->language, "");
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();
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
@@ -276,9 +276,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;
}
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 376f5e059..28f20d485 100755
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -64,7 +64,7 @@ static int silencesuppression = 0;
static int silencethreshold = 1000;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *type = "Console";
static char *desc = "OSS Console Channel Driver";
@@ -490,9 +490,9 @@ static int oss_hangup(struct ast_channel *c)
c->pvt->pvt = NULL;
oss.owner = NULL;
ast_verbose( " << Hangup on console >> \n");
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_lock(&usecnt_lock);
usecnt--;
- ast_pthread_mutex_unlock(&usecnt_lock);
+ ast_mutex_unlock(&usecnt_lock);
if (hookstate) {
if (autoanswer) {
/* Assume auto-hangup too */
@@ -712,9 +712,9 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
strncpy(tmp->language, language, sizeof(tmp->language)-1);
p->owner = tmp;
ast_setstate(tmp, state);
- 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();
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
@@ -1029,9 +1029,9 @@ char *description()
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;
}
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 80232c3c8..5ae642a1f 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -56,14 +56,14 @@ static int silencesupression = 0;
static int prefformat = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of phone_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. */
@@ -221,11 +221,11 @@ static int phone_hangup(struct ast_channel *ast)
p->dialtone = 0;
memset(p->ext, 0, sizeof(p->ext));
((struct phone_pvt *)(ast->pvt->pvt))->owner = NULL;
- 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);
@@ -640,9 +640,9 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
if (strlen(i->callerid))
tmp->callerid = strdup(i->callerid);
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();
if (state != AST_STATE_DOWN) {
if (state == AST_STATE_RING) {
@@ -695,9 +695,9 @@ static void phone_check_exception(struct phone_pvt *i)
phone_new(i, AST_STATE_RING, i->context);
/* No need to restart monitor, we are the monitor */
if (i->owner) {
- 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();
}
} else if (!ast_canmatch_extension(NULL, i->context, i->ext, 1, i->callerid)) {
@@ -707,9 +707,9 @@ static void phone_check_exception(struct phone_pvt *i)
/* Check the default, too... */
phone_new(i, AST_STATE_RING, "default");
if (i->owner) {
- 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();
}
/* XXX This should probably be justified better XXX */
@@ -732,9 +732,9 @@ static void phone_check_exception(struct phone_pvt *i)
if (i->mode == MODE_IMMEDIATE) {
phone_new(i, AST_STATE_RING, i->context);
} else if (i->mode == MODE_DIALTONE) {
- 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();
/* Reset the extension */
i->ext[0] = '\0';
@@ -747,9 +747,9 @@ static void phone_check_exception(struct phone_pvt *i)
}
} else {
if (i->dialtone) {
- 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();
}
memset(i->ext, 0, sizeof(i->ext));
@@ -793,14 +793,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
@@ -834,10 +834,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);
/* Wait indefinitely for something to happen */
if (dotone) {
/* If we're ready to recycle the time, set it to 30 ms */
@@ -866,7 +866,7 @@ static void *do_monitor(void *data)
continue;
/* 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;
}
@@ -888,7 +888,7 @@ static void *do_monitor(void *data)
}
i=i->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
}
/* Never reached */
return NULL;
@@ -900,12 +900,12 @@ static int restart_monitor()
/* 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;
}
@@ -917,11 +917,11 @@ static int restart_monitor()
}
/* 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;
}
@@ -997,7 +997,7 @@ static struct ast_channel *phone_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;
}
@@ -1011,7 +1011,7 @@ static struct ast_channel *phone_request(char *type, int format, void *data)
}
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
restart_monitor();
return tmp;
}
@@ -1053,7 +1053,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;
@@ -1070,7 +1070,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;
}
@@ -1118,7 +1118,7 @@ int load_module()
}
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Make sure we can register our Adtranphone channel type */
if (ast_channel_register(type, tdesc,
AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, phone_request)) {
@@ -1140,7 +1140,7 @@ int unload_module()
struct phone_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) {
@@ -1149,24 +1149,24 @@ 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 > -1) {
pthread_cancel(monitor_thread);
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) {
@@ -1179,7 +1179,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;
@@ -1191,9 +1191,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;
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a1b9adc6b..b4602275a 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -100,16 +100,16 @@ static int srvlookup = 0;
static int pedanticsipchecking = 0;
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 sip_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 netlock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t netlock = AST_MUTEX_INITIALIZER;
-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. */
@@ -168,7 +168,7 @@ struct sip_route {
};
static struct sip_pvt {
- pthread_mutex_t lock; /* Channel private lock */
+ ast_mutex_t lock; /* Channel private lock */
char callid[80]; /* Global CallID */
char randdata[80]; /* Random data */
unsigned int ocseq; /* Current outgoing seqno */
@@ -319,12 +319,12 @@ struct sip_peer {
static struct ast_user_list {
struct sip_user *users;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} userl = { NULL, AST_MUTEX_INITIALIZER };
static struct ast_peer_list {
struct sip_peer *peers;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
} peerl = { NULL, AST_MUTEX_INITIALIZER };
@@ -337,7 +337,7 @@ static struct ast_peer_list {
#define REG_STATE_NOAUTH 6
struct sip_registry {
- pthread_mutex_t lock; /* Channel private lock */
+ ast_mutex_t lock; /* Channel private lock */
struct sockaddr_in addr; /* Who we connect to for registration purposes */
char username[80]; /* Who we are registering as */
char authuser[80]; /* Who we *authenticate* as */
@@ -405,7 +405,7 @@ static int retrans_pkt(void *data)
{
struct sip_pkt *pkt=data;
int res = 0;
- ast_pthread_mutex_lock(&pkt->owner->lock);
+ ast_mutex_lock(&pkt->owner->lock);
if (1 /* !p->owner->needdestroy */) {
if (pkt->retrans < MAX_RETRANS) {
pkt->retrans++;
@@ -425,7 +425,7 @@ static int retrans_pkt(void *data)
ast_queue_hangup(pkt->owner->owner, 1);
} else {
/* If no owner, destroy now */
- ast_pthread_mutex_unlock(&pkt->owner->lock);
+ ast_mutex_unlock(&pkt->owner->lock);
sip_destroy(pkt->owner);
pkt = NULL;
}
@@ -438,13 +438,13 @@ static int retrans_pkt(void *data)
ast_queue_hangup(pkt->owner->owner, 1);
} else {
/* If no owner, destroy now */
- ast_pthread_mutex_unlock(&pkt->owner->lock);
+ ast_mutex_unlock(&pkt->owner->lock);
sip_destroy(pkt->owner);
pkt=NULL;
}
}
if (pkt)
- ast_pthread_mutex_unlock(&pkt->owner->lock);
+ ast_mutex_unlock(&pkt->owner->lock);
return res;
}
@@ -611,7 +611,7 @@ static int create_addr(struct sip_pvt *r, char *peer)
char host[256], *hostn;
r->sa.sin_family = AF_INET;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
p = peerl.peers;
while(p) {
if (!strcasecmp(p->name, peer)) {
@@ -668,7 +668,7 @@ static int create_addr(struct sip_pvt *r, char *peer)
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
if ((port=strchr(peer, ':'))) {
*port='\0';
@@ -710,16 +710,16 @@ static int create_addr(struct sip_pvt *r, char *peer)
static int auto_congest(void *nothing)
{
struct sip_pvt *p = nothing;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
p->initid = -1;
if (p->owner) {
- if (!pthread_mutex_trylock(&p->owner->lock)) {
+ if (!ast_mutex_trylock(&p->owner->lock)) {
ast_log(LOG_NOTICE, "Auto-congesting %s\n", p->owner->name);
ast_queue_control(p->owner, AST_CONTROL_CONGESTION, 0);
- ast_pthread_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->owner->lock);
}
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
@@ -856,11 +856,11 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner)
/* Unlink us from the owner if we have one */
if (p->owner) {
if (lockowner)
- ast_pthread_mutex_lock(&p->owner->lock);
+ ast_mutex_lock(&p->owner->lock);
ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
p->owner->pvt->pvt = NULL;
if (lockowner)
- ast_pthread_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->owner->lock);
}
cur = iflist;
while(cur) {
@@ -894,7 +894,7 @@ static int find_user(struct sip_pvt *fup, int event)
char name[256] = "";
struct sip_user *u;
strncpy(name, fup->username, sizeof(name) - 1);
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
u = userl.users;
while(u) {
if (!strcasecmp(u->name, name)) {
@@ -904,7 +904,7 @@ static int find_user(struct sip_pvt *fup, int event)
}
if (!u) {
ast_log(LOG_DEBUG, "%s is not a local user\n", name);
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return 0;
}
if(event == 0) {
@@ -917,22 +917,22 @@ static int find_user(struct sip_pvt *fup, int event)
if (u->incominglimit > 0 ) {
if (u->inUse >= u->incominglimit) {
ast_log(LOG_ERROR, "Call from user '%s' rejected due to usage limit of %d\n", u->name, u->incominglimit);
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return -1;
}
}
u->inUse++;
ast_log(LOG_DEBUG, "Call from user '%s' is %d out of %d\n", u->name, u->inUse, u->incominglimit);
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return 0;
}
static void sip_destroy(struct sip_pvt *p)
{
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
__sip_destroy(p, 1);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
}
static int transmit_response_reliable(struct sip_pvt *p, char *msg, struct sip_request *req);
@@ -949,13 +949,13 @@ static int sip_hangup(struct ast_channel *ast)
ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
ast_log(LOG_DEBUG, "find_user(%s)\n", p->username);
find_user(p, 0);
/* Determine how to disconnect */
if (p->owner != ast) {
ast_log(LOG_WARNING, "Huh? We aren't the owner?\n");
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
if (!ast || (ast->_state != AST_STATE_UP))
@@ -992,7 +992,7 @@ static int sip_hangup(struct ast_channel *ast)
}
}
p->needdestroy = needdestroy;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
@@ -1035,7 +1035,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
return -1;
}
if (p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->rtp) {
if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) {
transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0);
@@ -1043,11 +1043,11 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
}
res = ast_rtp_write(p->rtp, frame);
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
}
} else if (frame->frametype == AST_FRAME_VIDEO) {
if (p) {
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->vrtp) {
if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) {
transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0);
@@ -1055,7 +1055,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
}
res = ast_rtp_write(p->vrtp, frame);
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
}
} else if (frame->frametype == AST_FRAME_IMAGE) {
return 0;
@@ -1070,14 +1070,14 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
struct sip_pvt *p = newchan->pvt->pvt;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
if (p->owner != oldchan) {
ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return -1;
}
p->owner = newchan;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
@@ -1220,9 +1220,9 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title)
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);
strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
@@ -1370,9 +1370,9 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
{
struct ast_frame *fr;
struct sip_pvt *p = ast->pvt->pvt;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
fr = sip_rtp_read(ast, p);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return fr;
}
@@ -1427,7 +1427,7 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
if (p->vrtp)
ast_rtp_setnat(p->vrtp, p->nat);
}
- ast_pthread_mutex_init(&p->lock);
+ ast_mutex_init(&p->lock);
if (sin) {
memcpy(&p->sa, sin, sizeof(p->sa));
@@ -1450,10 +1450,10 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
strncpy(p->context, context, sizeof(p->context) - 1);
strncpy(p->fromdomain, fromdomain, sizeof(p->fromdomain) - 1);
/* Add to list */
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
p->next = iflist;
iflist = p;
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
if (option_debug)
ast_log(LOG_DEBUG, "Allocating new SIP call for %s\n", callid);
return p;
@@ -1506,22 +1506,22 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
ast_log(LOG_WARNING, "Call missing call ID from '%s'\n", inet_ntoa(sin->sin_addr));
return NULL;
}
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
p = iflist;
while(p) {
if (!strcmp(p->callid, callid) &&
(!pedanticsipchecking || !strlen(p->theirtag) || !strcmp(p->theirtag, tag))) {
/* Found the call */
- ast_pthread_mutex_lock(&p->lock);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_lock(&p->lock);
+ ast_mutex_unlock(&iflock);
return p;
}
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
p = sip_alloc(callid, sin, 1);
if (p)
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
return p;
}
@@ -1923,11 +1923,15 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, struct s
tmp = __get_header(orig, field, &start);
if (strlen(tmp)) {
if (!copied && p->nat) {
+#ifdef THE_SIP_AUTHORS_CAN_SUCK_MY_GONADS
/* SLD: FIXME: Nice try, but the received= should not have a port */
/* SLD: FIXME: See RFC2543 BNF in Section 6.40.5 */
+ /* MAS: Yup, RFC says you can't do it. No way to indicate PAT...
+ good job fellas. */
if (ntohs(p->recv.sin_port) != DEFAULT_SIP_PORT)
snprintf(new, sizeof(new), "%s;received=%s:%d", tmp, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
else
+#endif
snprintf(new, sizeof(new), "%s;received=%s", tmp, inet_ntoa(p->recv.sin_addr));
add_header(req, field, new);
} else {
@@ -2759,9 +2763,9 @@ static int sip_reregister(void *data)
static int sip_do_register(struct sip_registry *r)
{
int res;
- ast_pthread_mutex_lock(&r->lock);
+ ast_mutex_lock(&r->lock);
res=transmit_register(r, "REGISTER", NULL);
- ast_pthread_mutex_unlock(&r->lock);
+ ast_mutex_unlock(&r->lock);
return res;
}
@@ -2771,7 +2775,7 @@ static int sip_reg_timeout(void *data)
struct sip_registry *r=data;
struct sip_pvt *p;
int res;
- ast_pthread_mutex_lock(&r->lock);
+ ast_mutex_lock(&r->lock);
ast_log(LOG_NOTICE, "Registration for '%s@%s' timed out, trying again\n", r->username, inet_ntoa(r->addr.sin_addr));
if (r->call) {
/* Unlink us, destroy old call. Locking is not relevent here because all this happens
@@ -2784,7 +2788,7 @@ static int sip_reg_timeout(void *data)
r->regstate=REG_STATE_UNREGISTERED;
r->timeout = -1;
res=transmit_register(r, "REGISTER", NULL);
- ast_pthread_mutex_unlock(&r->lock);
+ ast_mutex_unlock(&r->lock);
return 0;
}
@@ -3326,7 +3330,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
*c = '\0';
strncpy(p->exten, name, sizeof(p->exten) - 1);
build_contact(p);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!strcasecmp(peer->name, name) && peer->dynamic) {
@@ -3347,7 +3351,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!res) {
ast_device_state_changed("SIP/%s", peer->name);
}
@@ -3492,19 +3496,19 @@ static int get_refer_info(struct sip_pvt *p, struct sip_request *oreq)
strncpy(p->refer_contact, "", sizeof(p->refer_contact) - 1);
strncpy(p->remote_party_id, "", sizeof(p->remote_party_id) - 1);
p->refer_call = NULL;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
/* Search interfaces and find the match */
p2 = iflist;
while(p2) {
if (!strcmp(p2->callid, tmp5)) {
/* Go ahead and lock it before returning */
- ast_pthread_mutex_lock(&p2->lock);
+ ast_mutex_lock(&p2->lock);
p->refer_call = p2;
break;
}
p2 = p2->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
if (p->refer_call)
return 0;
else
@@ -3633,7 +3637,7 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
strncpy(p->callerid, of, sizeof(p->callerid) - 1);
if (!strlen(of))
return 0;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user = userl.users;
while(user) {
if (!strcasecmp(user->name, of)) {
@@ -3670,10 +3674,10 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
}
user = user->next;
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
if (!user) {
/* If we didn't find a user match, check for peers */
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!inaddrcmp(&peer->addr, &p->recv) ||
@@ -3705,7 +3709,7 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
}
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
return res;
}
@@ -3750,7 +3754,7 @@ static int sip_show_inuse(int fd, int argc, char *argv[]) {
char used[80];
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user = userl.users;
ast_cli(fd, FORMAT, "Username", "inUse", "Limit");
for(user=userl.users;user;user=user->next) {
@@ -3761,7 +3765,7 @@ static int sip_show_inuse(int fd, int argc, char *argv[]) {
snprintf(used, sizeof(used), "%d", user->inUse);
ast_cli(fd, FORMAT2, user->name, used, limits);
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -3774,13 +3778,13 @@ static int sip_show_users(int fd, int argc, char *argv[])
struct sip_user *user;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
ast_cli(fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C");
for(user=userl.users;user;user=user->next) {
ast_cli(fd, FORMAT, user->name, user->secret, user->methods,
user->context,user->ha ? "Yes" : "No");
}
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
return RESULT_SUCCESS;
#undef FORMAT
}
@@ -3793,7 +3797,7 @@ static int sip_show_peers(int fd, int argc, char *argv[])
char name[256] = "";
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
ast_cli(fd, FORMAT2, "Name/username", "Host", " ", "Mask", "Port", "Status");
for (peer = peerl.peers;peer;peer = peer->next) {
char nm[20] = "";
@@ -3820,7 +3824,7 @@ static int sip_show_peers(int fd, int argc, char *argv[])
nm,
ntohs(peer->addr.sin_port), status);
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -3856,14 +3860,14 @@ static int sip_show_registry(int fd, int argc, char *argv[])
char host[80];
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
ast_cli(fd, FORMAT2, "Host", "Username", "Refresh", "State");
for (reg = registrations;reg;reg = reg->next) {
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
ast_cli(fd, FORMAT, host,
reg->username, reg->refresh, regstate2str(reg->regstate));
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -3877,7 +3881,7 @@ static int sip_show_channels(int fd, int argc, char *argv[])
int numchans = 0;
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
cur = iflist;
ast_cli(fd, FORMAT2, "Peer", "User/ANR", "Call ID", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
while (cur) {
@@ -3893,7 +3897,7 @@ static int sip_show_channels(int fd, int argc, char *argv[])
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
ast_cli(fd, "%d active SIP channel(s)\n", numchans);
return RESULT_SUCCESS;
#undef FORMAT
@@ -3905,7 +3909,7 @@ static char *complete_sipch(char *line, char *word, int pos, int state)
int which=0;
struct sip_pvt *cur;
char *c = NULL;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
cur = iflist;
while(cur) {
if (!strncasecmp(word, cur->callid, strlen(word))) {
@@ -3916,7 +3920,7 @@ static char *complete_sipch(char *line, char *word, int pos, int state)
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return c;
}
@@ -3926,7 +3930,7 @@ static int sip_show_channel(int fd, int argc, char *argv[])
char tmp[256];
if (argc != 4)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
cur = iflist;
while(cur) {
if (!strcasecmp(cur->callid, argv[3])) {
@@ -3950,7 +3954,7 @@ static int sip_show_channel(int fd, int argc, char *argv[])
}
cur = cur->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
if (!cur)
ast_cli(fd, "No such SIP Call ID '%s'\n", argv[3]);
return RESULT_SUCCESS;
@@ -4643,7 +4647,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
build_route(p, req, 0);
if (c) {
/* Pre-lock the call */
- ast_pthread_mutex_lock(&c->lock);
+ ast_mutex_lock(&c->lock);
}
}
@@ -4660,10 +4664,10 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
if (ast_pbx_start(c)) {
ast_log(LOG_WARNING, "Failed to start PBX :(\n");
/* Unlock locks so ast_hangup can do its magic */
- ast_pthread_mutex_unlock(&c->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&c->lock);
+ ast_mutex_unlock(&p->lock);
ast_hangup(c);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
transmit_response_reliable(p, "503 Unavailable", req);
c = NULL;
}
@@ -4672,16 +4676,16 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
transmit_response_reliable(p, "503 Unavailable", req);
p->alreadygone = 1;
/* Unlock locks so ast_hangup can do its magic */
- ast_pthread_mutex_unlock(&c->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&c->lock);
+ ast_mutex_unlock(&p->lock);
ast_hangup(c);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
c = NULL;
} else {
- ast_pthread_mutex_unlock(&c->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&c->lock);
+ ast_mutex_unlock(&p->lock);
ast_hangup(c);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
c = NULL;
}
break;
@@ -4720,7 +4724,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
if (p->refer_call) {
ast_log(LOG_DEBUG,"202 Accepted (supervised)\n");
attempt_transfer(p, p->refer_call);
- ast_pthread_mutex_unlock(&p->refer_call->lock);
+ ast_mutex_unlock(&p->refer_call->lock);
p->refer_call = NULL;
} else {
ast_log(LOG_DEBUG,"202 Accepted (blind)\n");
@@ -4909,26 +4913,26 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
return 1;
}
/* Process request, with netlock held */
- ast_pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
p = find_call(&req, &sin);
if (p) {
retrylock:
/* Go ahead and lock the owner if it has one -- we may need it */
- if (p->owner && pthread_mutex_trylock(&p->owner->lock)) {
+ if (p->owner && ast_mutex_trylock(&p->owner->lock)) {
ast_log(LOG_DEBUG, "Failed to grab lock, trying again...\n");
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
/* Sleep infintismly short amount of time */
usleep(1);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
goto retrylock;
}
memcpy(&p->recv, &sin, sizeof(p->recv));
handle_request(p, &req, &sin);
if (p->owner)
- ast_pthread_mutex_unlock(&p->owner->lock);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->owner->lock);
+ ast_mutex_unlock(&p->lock);
}
- ast_pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
return 1;
}
@@ -4945,19 +4949,19 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer)
/* Return now if it's the same thing we told them last time */
if (((newmsgs << 8) | (oldmsgs)) == peer->lastmsgssent) {
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return 0;
}
p = sip_alloc(NULL, NULL, 0);
if (!p) {
ast_log(LOG_WARNING, "Unable to build sip pvt data for MWI\n");
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return -1;
}
strncpy(name, peer->name, sizeof(name) - 1);
peer->lastmsgssent = ((newmsgs << 8) | (oldmsgs));
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (create_addr(p, name)) {
/* Maybe they're not registered, etc. */
sip_destroy(p);
@@ -4994,29 +4998,29 @@ static void *do_monitor(void *data)
/* From here on out, we die whenever asked */
for(;;) {
/* Check for interfaces needing to be killed */
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
restartsearch:
sip = iflist;
while(sip) {
- ast_pthread_mutex_lock(&sip->lock);
+ ast_mutex_lock(&sip->lock);
if (sip->needdestroy && !sip->packets) {
- ast_pthread_mutex_unlock(&sip->lock);
+ ast_mutex_unlock(&sip->lock);
__sip_destroy(sip, 1);
goto restartsearch;
}
- ast_pthread_mutex_unlock(&sip->lock);
+ ast_mutex_unlock(&sip->lock);
sip = sip->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* 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. */
- ast_pthread_mutex_lock(&monlock);
+ ast_mutex_lock(&monlock);
/* Lock the network interface */
- ast_pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
/* Okay, now that we know what to do, release the network lock */
- ast_pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
/* 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 for sched or io */
res = ast_sched_wait(sched);
@@ -5026,10 +5030,10 @@ restartsearch:
if (fastrestart)
res = 1;
res = ast_io_wait(io, res);
- ast_pthread_mutex_lock(&monlock);
+ ast_mutex_lock(&monlock);
if (res >= 0)
ast_sched_runq(sched);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
time(&t);
fastrestart = 0;
@@ -5048,9 +5052,9 @@ restartsearch:
if (!peer) {
/* Reset where we come from */
lastpeernum = -1;
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
}
/* Never reached */
return NULL;
@@ -5062,12 +5066,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;
}
@@ -5077,12 +5081,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;
}
@@ -5176,7 +5180,7 @@ static int sip_devicestate(void *data)
ext = NULL;
}
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
p = peerl.peers;
while (p) {
if (!strcasecmp(p->name, host)) {
@@ -5191,7 +5195,7 @@ static int sip_devicestate(void *data)
}
p = p->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
hp = gethostbyname(host);
if (hp)
@@ -5344,7 +5348,7 @@ static struct sip_peer *build_peer(char *name, struct ast_variable *v)
int format;
int found=0;
prev = NULL;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer = peerl.peers;
while(peer) {
if (!strcasecmp(peer->name, name)) {
@@ -5361,9 +5365,9 @@ static struct sip_peer *build_peer(char *name, struct ast_variable *v)
} else {
peerl.peers = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
} else {
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
peer = malloc(sizeof(struct sip_peer));
memset(peer, 0, sizeof(struct sip_peer));
peer->expire = -1;
@@ -5637,19 +5641,19 @@ static int reload_config(void)
if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
user = build_user(cat, ast_variable_browse(cfg, cat));
if (user) {
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
user->next = userl.users;
userl.users = user;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
}
}
if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
peer = build_peer(cat, ast_variable_browse(cfg, cat));
if (peer) {
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peer->next = peerl.peers;
peerl.peers = peer;
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
} else if (strcasecmp(utype, "user")) {
ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, "sip.conf");
@@ -5673,7 +5677,7 @@ static int reload_config(void)
if (!ntohs(bindaddr.sin_port))
bindaddr.sin_port = ntohs(DEFAULT_SIP_PORT);
bindaddr.sin_family = AF_INET;
- pthread_mutex_lock(&netlock);
+ ast_mutex_lock(&netlock);
if ((sipsock > -1) && (ntohs(bindaddr.sin_port) != oldport)) {
close(sipsock);
sipsock = -1;
@@ -5706,7 +5710,7 @@ static int reload_config(void)
}
}
}
- pthread_mutex_unlock(&netlock);
+ ast_mutex_unlock(&netlock);
ast_destroy(cfg);
return 0;
@@ -5787,14 +5791,14 @@ int load_module()
ast_log(LOG_WARNING, "Unable to create I/O context\n");
}
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer = peerl.peers; peer; peer = peer->next)
sip_poke_peer(peer);
for (reg = registrations; reg; reg = reg->next)
sip_do_register(reg);
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
/* And start the monitor for the first time */
restart_monitor();
@@ -5809,7 +5813,7 @@ static void delete_users(void)
struct sip_registry *reg, *regl;
/* Delete all users */
- ast_pthread_mutex_lock(&userl.lock);
+ ast_mutex_lock(&userl.lock);
for (user=userl.users;user;) {
ast_free_ha(user->ha);
userlast = user;
@@ -5817,7 +5821,7 @@ static void delete_users(void)
free(userlast);
}
userl.users=NULL;
- ast_pthread_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&userl.lock);
for (reg = registrations;reg;) {
regl = reg;
@@ -5827,20 +5831,20 @@ static void delete_users(void)
free(regl);
}
registrations = NULL;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer=peerl.peers;peer;) {
/* Assume all will be deleted, and we'll find out for sure later */
peer->delme = 1;
peer = peer->next;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
static void prune_peers(void)
{
/* Prune peers who still are supposed to be deleted */
struct sip_peer *peer, *peerlast, *peernext;
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
peerlast = NULL;
for (peer=peerl.peers;peer;) {
peernext = peer->next;
@@ -5861,7 +5865,7 @@ static void prune_peers(void)
peerlast = peer;
peer=peernext;
}
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
int reload(void)
@@ -5876,10 +5880,10 @@ int reload(void)
restart_monitor();
for (reg = registrations; reg; reg = reg->next)
sip_do_register(reg);
- ast_pthread_mutex_lock(&peerl.lock);
+ ast_mutex_lock(&peerl.lock);
for (peer = peerl.peers; peer; peer = peer->next)
sip_poke_peer(peer);
- ast_pthread_mutex_unlock(&peerl.lock);
+ ast_mutex_unlock(&peerl.lock);
return 0;
}
@@ -5889,7 +5893,7 @@ int unload_module()
/* 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) {
@@ -5898,25 +5902,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) {
@@ -5926,7 +5930,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;
@@ -5938,9 +5942,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;
}
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;
}
diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c
index 7c7353bab..74f6c4ea8 100755
--- a/channels/chan_vpb.c
+++ b/channels/chan_vpb.c
@@ -71,14 +71,14 @@ static int silencesupression = 0;
static const int prefformat = AST_FORMAT_ALAW | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ADPCM;
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
/* Protect the interface list (of vpb_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. */
@@ -110,11 +110,11 @@ static struct vpb_bridge_t {
struct ast_frame **fo;
int flags;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
pthread_cond_t cond;
} bridges[VPB_MAX_BRIDGES]; /* Bridges...*/
-static pthread_mutex_t bridge_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t bridge_lock = AST_MUTEX_INITIALIZER;
static struct vpb_pvt {
@@ -148,7 +148,7 @@ static struct vpb_pvt {
int lastgrunt;
- pthread_mutex_t lock;
+ ast_mutex_t lock;
int stopreads; /* Stop reading...*/
pthread_t readthread; /* For monitoring read channel. One per owned channel. */
@@ -166,7 +166,7 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
/* Bridge channels, check if we can. I believe we always can, so find a slot.*/
- ast_pthread_mutex_lock(&bridge_lock); {
+ ast_mutex_lock(&bridge_lock); {
for (i = 0; i < len; i++)
if (!bridges[i].inuse)
break;
@@ -180,7 +180,7 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
pthread_mutex_init(&bridges[i].lock, NULL);
pthread_cond_init(&bridges[i].cond, NULL);
}
- } ast_pthread_mutex_unlock(&bridge_lock);
+ } ast_mutex_unlock(&bridge_lock);
if (i == len) {
ast_log(LOG_WARNING, "Failed to bridge %s and %s!\n", c0->name, c1->name);
@@ -188,13 +188,13 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
} else {
/* Set bridge pointers. You don't want to take these locks while holding bridge lock.*/
- ast_pthread_mutex_lock(&p0->lock); {
+ ast_mutex_lock(&p0->lock); {
p0->bridge = &bridges[i];
- } ast_pthread_mutex_unlock(&p0->lock);
+ } ast_mutex_unlock(&p0->lock);
- ast_pthread_mutex_lock(&p1->lock); {
+ ast_mutex_lock(&p1->lock); {
p1->bridge = &bridges[i];
- } ast_pthread_mutex_unlock(&p1->lock);
+ } ast_mutex_unlock(&p1->lock);
if (option_verbose > 4)
ast_verbose(VERBOSE_PREFIX_3
@@ -213,19 +213,19 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
vpb_bridge(p0->handle, p1->handle, VPB_BRIDGE_OFF, 0);
- ast_pthread_mutex_lock(&bridge_lock); {
+ ast_mutex_lock(&bridge_lock); {
bridges[i].inuse = 0;
pthread_mutex_destroy(&bridges[i].lock);
pthread_cond_destroy(&bridges[i].cond);
- } ast_pthread_mutex_unlock(&bridge_lock);
+ } ast_mutex_unlock(&bridge_lock);
- ast_pthread_mutex_lock(&p0->lock); {
+ ast_mutex_lock(&p0->lock); {
p0->bridge = NULL;
- } ast_pthread_mutex_unlock(&p0->lock);
+ } ast_mutex_unlock(&p0->lock);
- ast_pthread_mutex_lock(&p1->lock); {
+ ast_mutex_lock(&p1->lock); {
p1->bridge = NULL;
- } ast_pthread_mutex_unlock(&p1->lock);
+ } ast_mutex_unlock(&p1->lock);
if (option_verbose > 4)
@@ -318,7 +318,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
ast_verbose(VERBOSE_PREFIX_3 " handle_owned: putting frame: [%d=>%d], bridge=%p\n",
f.frametype, f.subclass, (void *)p->bridge);
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
if (p->bridge) { /* Check what happened, see if we need to report it. */
switch (f.frametype) {
case AST_FRAME_DTMF:
@@ -350,12 +350,12 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
if (p->bridge->rc)
*p->bridge->rc = p->owner;
- ast_pthread_mutex_lock(&p->bridge->lock); {
+ ast_mutex_lock(&p->bridge->lock); {
pthread_cond_signal(&p->bridge->cond);
- } ast_pthread_mutex_unlock(&p->bridge->lock);
+ } ast_mutex_unlock(&p->bridge->lock);
}
}
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
if (endbridge) return 0;
@@ -450,8 +450,8 @@ static void *do_monitor(void *unused)
goto end_loop;
str[0] = 0;
- ast_pthread_mutex_lock(&monlock),
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&monlock),
+ ast_mutex_lock(&iflock); {
struct vpb_pvt *p = iflist; /* Find the pvt structure */
vpb_translate_event(&e, str);
@@ -480,8 +480,8 @@ static void *do_monitor(void *unused)
monitor_handle_notowned(p, &e);
done: (void)0;
- } ast_pthread_mutex_unlock(&iflock);
- ast_pthread_mutex_unlock(&monlock);
+ } ast_mutex_unlock(&iflock);
+ ast_mutex_unlock(&monlock);
end_loop:
tcounter += VPB_WAIT_TIMEOUT; /* Ok, not quite but will suffice. */
@@ -499,7 +499,7 @@ static int restart_monitor(void)
/* If we're supposed to be stopped -- stay stopped */
if (mthreadactive == -2)
return 0;
- ast_pthread_mutex_lock(&monlock); {
+ ast_mutex_lock(&monlock); {
if (monitor_thread == pthread_self()) {
ast_log(LOG_WARNING, "Cannot kill myself\n");
error = -1;
@@ -531,7 +531,7 @@ static int restart_monitor(void)
#endif
}
done: (void)0;
- } ast_pthread_mutex_unlock(&monlock);
+ } ast_mutex_unlock(&monlock);
return error;
}
@@ -744,18 +744,18 @@ static int vpb_hangup(struct ast_channel *ast)
ast_setstate(ast,AST_STATE_DOWN);
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
p->lastinput = p->lastoutput = -1;
p->ext[0] = 0;
p->owner = NULL;
p->dialtone = 0;
p->calling = 0;
ast->pvt->pvt = NULL;
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
- 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();
/* Stop thread doing reads. */
@@ -913,7 +913,7 @@ static void *do_chanreads(void *pvt)
p->lastinput = fmt;
}
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
if (p->bridge)
if (p->bridge->c0 == p->owner &&
(p->bridge->flags & AST_BRIDGE_REC_CHANNEL_0))
@@ -925,7 +925,7 @@ static void *do_chanreads(void *pvt)
bridgerec = 0;
else
bridgerec = 1;
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
if (state == AST_STATE_UP && bridgerec) {
/* Read only if up and not bridged, or a bridge for which we can read. */
@@ -941,9 +941,9 @@ static void *do_chanreads(void *pvt)
fr->datalen = readlen;
fr->offset = AST_FRIENDLY_OFFSET;
- ast_pthread_mutex_lock(&p->lock); {
+ ast_mutex_lock(&p->lock); {
if (p->owner) ast_queue_frame(p->owner, fr, 0);
- } ast_pthread_mutex_unlock(&p->lock);
+ } ast_mutex_unlock(&p->lock);
} else
p->stopreads = 1;
@@ -1009,9 +1009,9 @@ static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context)
i->lastinput = i->lastoutput = -1;
i->lastgrunt = tcounter; /* Assume at least one grunt tone seen now. */
- 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();
if (state != AST_STATE_DOWN)
if (ast_pbx_start(tmp)) {
@@ -1047,7 +1047,7 @@ static struct ast_channel *vpb_request(char *type, int format, void *data)
if (!s)
s = "";
/* Search for an unowned channel */
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
p = iflist;
while(p) {
if (strncmp(s, p->dev + 4, sizeof p->dev) == 0)
@@ -1057,7 +1057,7 @@ static struct ast_channel *vpb_request(char *type, int format, void *data)
}
p = p->next;
}
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
if (option_verbose > 2)
@@ -1114,7 +1114,7 @@ int load_module()
vpb_seterrormode(VPB_DEVELOPMENT);
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
v = ast_variable_browse(cfg, "interfaces");
while(v) {
/* Create the interface list */
@@ -1176,7 +1176,7 @@ int load_module()
gruntdetect_timeout = 1000;
done: (void)0;
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
ast_destroy(cfg);
@@ -1205,7 +1205,7 @@ int unload_module()
/* First, take us out of the channel loop */
ast_channel_unregister(type);
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
@@ -1214,17 +1214,17 @@ int unload_module()
p = p->next;
}
iflist = NULL;
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
- ast_pthread_mutex_lock(&monlock); {
+ ast_mutex_lock(&monlock); {
if (mthreadactive > -1) {
pthread_cancel(monitor_thread);
pthread_join(monitor_thread, NULL);
}
mthreadactive = -2;
- } ast_pthread_mutex_unlock(&monlock);
+ } ast_mutex_unlock(&monlock);
- ast_pthread_mutex_lock(&iflock); {
+ ast_mutex_lock(&iflock); {
/* Destroy all the interfaces and free their memory */
while(iflist) {
@@ -1238,11 +1238,11 @@ int unload_module()
free(p);
}
iflist = NULL;
- } ast_pthread_mutex_unlock(&iflock);
+ } ast_mutex_unlock(&iflock);
- ast_pthread_mutex_lock(&bridge_lock); {
+ ast_mutex_lock(&bridge_lock); {
memset(bridges, 0, sizeof bridges);
- } ast_pthread_mutex_unlock(&bridge_lock);
+ } ast_mutex_unlock(&bridge_lock);
pthread_mutex_destroy(&bridge_lock);
tcounter = 0;
@@ -1253,9 +1253,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;
}
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 382890e05..09a2db606 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -200,14 +200,14 @@ static int gendigittimeout = 8000;
static int matchdigittimeout = 3000;
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 zt_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. */
@@ -260,7 +260,7 @@ static int r2prot = -1;
#ifdef ZAPATA_PRI
struct zt_pri {
pthread_t master; /* Thread of master */
- pthread_mutex_t lock; /* Mutex */
+ ast_mutex_t lock; /* Mutex */
char idleext[AST_MAX_EXTENSION]; /* Where to idle extra calls */
char idlecontext[AST_MAX_EXTENSION]; /* What context to use for idle */
char idledial[AST_MAX_EXTENSION]; /* What to dial before dumping */
@@ -299,7 +299,7 @@ static int pritype = PRI_CPE;
static inline void pri_rel(struct zt_pri *pri)
{
- ast_pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
static int switchtype = PRI_SWITCH_NI2;
@@ -337,7 +337,7 @@ struct zt_subchannel {
#define MAX_SLAVES 4
static struct zt_pvt {
- pthread_mutex_t lock;
+ ast_mutex_t lock;
struct ast_channel *owner; /* Our current active owner (if applicable) */
/* Up to three channels can be associated with this call */
@@ -457,12 +457,12 @@ static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
int res;
/* Grab the lock first */
do {
- res = pthread_mutex_trylock(&pri->lock);
+ res = ast_mutex_trylock(&pri->lock);
if (res) {
- ast_pthread_mutex_unlock(&pvt->lock);
+ ast_mutex_unlock(&pvt->lock);
/* Release the lock and try again */
usleep(1);
- ast_pthread_mutex_lock(&pvt->lock);
+ ast_mutex_lock(&pvt->lock);
}
} while(res);
/* Then break the select */
@@ -1490,7 +1490,7 @@ static int zt_hangup(struct ast_channel *ast)
return 0;
}
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 1);
@@ -1726,17 +1726,17 @@ static int zt_hangup(struct ast_channel *ast)
p->callwaitingrepeat = 0;
p->cidcwexpire = 0;
ast->pvt->pvt = NULL;
- ast_pthread_mutex_unlock(&p->lock);
- ast_pthread_mutex_lock(&usecnt_lock);
+ ast_mutex_unlock(&p->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);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
prev = NULL;
if (p->destroy) {
@@ -1750,7 +1750,7 @@ static int zt_hangup(struct ast_channel *ast)
}
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return 0;
}
@@ -1761,13 +1761,13 @@ static int zt_answer(struct ast_channel *ast)
int index;
int oldstate = ast->_state;
ast_setstate(ast, AST_STATE_UP);
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 0);
if (index < 0)
index = SUB_REAL;
/* nothing to do if a radio channel */
if (p->radio) {
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
}
switch(p->sig) {
@@ -1823,13 +1823,13 @@ static int zt_answer(struct ast_channel *ast)
break;
#endif
case 0:
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return 0;
default:
ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
res = -1;
}
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -2061,8 +2061,8 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
/* cant do pseudo-channels here */
if ((!p0->sig) || (!p1->sig)) return -2;
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
op0 = p0 = c0->pvt->pvt;
op1 = p1 = c1->pvt->pvt;
ofd1 = c0->fds[0];
@@ -2076,12 +2076,12 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
- ast_pthread_mutex_lock(&p0->lock);
- if (pthread_mutex_trylock(&p1->lock)) {
+ ast_mutex_lock(&p0->lock);
+ if (ast_mutex_trylock(&p1->lock)) {
/* Don't block, due to potential for deadlock */
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
return -3;
}
@@ -2184,11 +2184,11 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
t1 = p0->subs[SUB_REAL].inthreeway;
t2 = p1->subs[SUB_REAL].inthreeway;
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&p1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&p1->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
/* Native bridge failed */
if ((!master || !slave) && !nothingok) {
@@ -2205,16 +2205,16 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
for (;;) {
/* Here's our main loop... Start by locking things, looking for private parts,
and then balking if anything is wrong */
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
p0 = c0->pvt->pvt;
p1 = c1->pvt->pvt;
if (op0 == p0)
i1 = zt_get_index(c0, p0, 1);
if (op1 == p1)
i2 = zt_get_index(c1, p1, 1);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
if ((op0 != p0) || (op1 != p1) ||
(ofd1 != c0->fds[0]) ||
(ofd2 != c1->fds[0]) ||
@@ -2984,7 +2984,7 @@ struct ast_frame *zt_exception(struct ast_channel *ast)
int index;
struct ast_frame *f;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 1);
@@ -3062,7 +3062,7 @@ struct ast_frame *zt_exception(struct ast_channel *ast)
ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", event2str(res));
}
f = &p->subs[index].f;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
if (!p->radio) ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
@@ -3070,11 +3070,11 @@ struct ast_frame *zt_exception(struct ast_channel *ast)
if (ast != p->owner) {
ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
f = &p->subs[index].f;
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
f = zt_handle_event(ast);
- ast_pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
@@ -3087,7 +3087,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
struct ast_frame *f;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 0);
@@ -3103,7 +3103,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
/* Hang up if we don't really exist */
if (index < 0) {
ast_log(LOG_WARNING, "We dont exist?\n");
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
@@ -3125,11 +3125,11 @@ struct ast_frame *zt_read(struct ast_channel *ast)
{
p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
if (p->ringt == 1) {
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
else if (p->ringt > 0)
@@ -3141,7 +3141,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_RINGING;
ast_setstate(ast, AST_STATE_RINGING);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
@@ -3156,7 +3156,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
@@ -3177,7 +3177,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
}
} else {
ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
@@ -3189,18 +3189,18 @@ struct ast_frame *zt_read(struct ast_channel *ast)
if (res == -1) {
if (errno == EAGAIN) {
/* Return "NULL" frame if there is nobody there */
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
} else
ast_log(LOG_WARNING, "zt_rec: %s\n", strerror(errno));
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
f = zt_handle_event(ast);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
if (p->tdd) { /* if in TDD mode, see if we receive that */
@@ -3219,7 +3219,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET;
p->subs[index].f.datalen = 1;
*((char *) p->subs[index].f.data) = c;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
}
@@ -3354,7 +3354,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
f = &p->subs[index].f;
}
#endif
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
@@ -3621,9 +3621,9 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
}
i->subs[index].owner = tmp;
ast_setstate(tmp, state);
- 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);
/* Copy call forward info */
@@ -4484,7 +4484,7 @@ static void *do_monitor(void *data)
#endif
for(;;) {
/* 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");
return NULL;
}
@@ -4515,7 +4515,7 @@ 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);
pthread_testcancel();
/* Wait at least a second for something to happen */
@@ -4531,7 +4531,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;
}
@@ -4649,7 +4649,7 @@ static void *do_monitor(void *data)
}
i=i->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
}
/* Never reached */
return NULL;
@@ -4664,12 +4664,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;
}
@@ -4685,7 +4685,7 @@ static int restart_monitor(void)
} else {
/* Start a new monitor */
if (pthread_create(&monitor_thread, &attr, 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;
}
@@ -4693,7 +4693,7 @@ static int restart_monitor(void)
#if 0
printf("Created thread %ld detached in restart monitor\n", monitor_thread);
#endif
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
return 0;
}
@@ -5006,7 +5006,7 @@ static struct zt_pvt *mkintf(int channel, int signalling, int radio)
tmp->propconfno = -1;
}
tmp->transfer = transfer;
- ast_pthread_mutex_init(&tmp->lock);
+ ast_mutex_init(&tmp->lock);
strncpy(tmp->language, language, sizeof(tmp->language)-1);
strncpy(tmp->musicclass, musicclass, sizeof(tmp->musicclass)-1);
strncpy(tmp->context, context, sizeof(tmp->context)-1);
@@ -5211,7 +5211,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
channelmatch = x;
}
/* 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;
}
@@ -5270,7 +5270,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
else
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
restart_monitor();
return tmp;
}
@@ -5457,7 +5457,7 @@ static void *pri_dchannel(void *vpri)
FD_SET(pri->fd, &rfds);
FD_SET(pri->fd, &efds);
time(&t);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (pri->resetting && pri->up) {
if (!pri->resetchannel)
pri_check_restart(pri);
@@ -5561,12 +5561,12 @@ static void *pri_dchannel(void *vpri)
tv.tv_sec = 60;
tv.tv_usec = 0;
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
e = NULL;
res = ast_select(pri->fd + 1, &rfds, NULL, &efds, &tv);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (!res) {
/* Just a timeout, run the scheduler */
e = pri_schedule_run(pri->pri);
@@ -5606,21 +5606,21 @@ static void *pri_dchannel(void *vpri)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "B-channel %d restarted on span %d\n",
chan, pri->span);
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
/* Force soft hangup if appropriate */
if (pri->pvt[chan]->owner)
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
}
} else {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_2 "Restart on requested on entire span %d\n", pri->span);
for (x=1;x <= pri->channels;x++)
if ((x != pri->dchannel) && pri->pvt[x]) {
- ast_pthread_mutex_lock(&pri->pvt[x]->lock);
+ ast_mutex_lock(&pri->pvt[x]->lock);
if (pri->pvt[x]->owner)
pri->pvt[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
- ast_pthread_mutex_unlock(&pri->pvt[x]->lock);
+ ast_mutex_unlock(&pri->pvt[x]->lock);
}
}
break;
@@ -5876,7 +5876,7 @@ static void *pri_dchannel(void *vpri)
if (chan) {
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
if (!pri->pvt[chan]->alreadyhungup) {
/* we're calling here zt_hangup so once we get there we need to clear p->call after calling pri_hangup */
pri->pvt[chan]->alreadyhungup = 1;
@@ -5894,7 +5894,7 @@ static void *pri_dchannel(void *vpri)
pri_reset(pri->pri, chan);
pri->pvt[chan]->resetting = 1;
}
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
} else {
ast_log(LOG_WARNING, "Hangup on bad channel %d\n", e->hangup.channel);
}
@@ -5915,7 +5915,7 @@ static void *pri_dchannel(void *vpri)
if (chan) {
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
if (pri->pvt[chan]->owner) {
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (option_verbose > 2)
@@ -5927,7 +5927,7 @@ static void *pri_dchannel(void *vpri)
pri_reset(pri->pri, chan);
pri->pvt[chan]->resetting = 1;
}
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
} else {
ast_log(LOG_WARNING, "Hangup REQ on bad channel %d\n", e->hangup.channel);
}
@@ -5945,14 +5945,14 @@ static void *pri_dchannel(void *vpri)
if (chan) {
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
pri->pvt[chan]->call = NULL;
pri->pvt[chan]->resetting = 0;
if (pri->pvt[chan]->owner) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Channel %d, span %d got hangup ACK\n", chan, pri->span);
}
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
}
}
break;
@@ -5968,7 +5968,7 @@ static void *pri_dchannel(void *vpri)
for (x=1;x<=pri->channels;x++) {
if (pri->pvt[x] && pri->pvt[x]->resetting) {
chan = x;
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d span %d\n", chan, pri->span);
if (pri->pvt[chan]->owner) {
ast_log(LOG_WARNING, "Got restart ack on channel %d with owner\n", chan);
@@ -5977,7 +5977,7 @@ static void *pri_dchannel(void *vpri)
pri->pvt[chan]->resetting = 0;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "B-channel %d successfully restarted on span %d\n", chan, pri->span);
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
if (pri->resetting)
pri_check_restart(pri);
break;
@@ -5993,7 +5993,7 @@ static void *pri_dchannel(void *vpri)
}
if ((chan >= 1) && (chan <= pri->channels)) {
if (pri->pvt[chan]) {
- ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
+ ast_mutex_lock(&pri->pvt[chan]->lock);
if (pri->pvt[chan]->owner) {
ast_log(LOG_WARNING, "Got restart ack on channel %d with owner\n", chan);
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -6001,7 +6001,7 @@ static void *pri_dchannel(void *vpri)
pri->pvt[chan]->resetting = 0;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "B-channel %d successfully restarted on span %d\n", chan, pri->span);
- ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
+ ast_mutex_unlock(&pri->pvt[chan]->lock);
if (pri->resetting)
pri_check_restart(pri);
}
@@ -6031,7 +6031,7 @@ static void *pri_dchannel(void *vpri)
if (option_debug)
ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
/* Never reached */
return NULL;
@@ -6302,7 +6302,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
ast_cli(fd, FORMAT2, "Chan. Num.", "Extension", "Context", "Language", "MusicOnHold");
tmp = iflist;
@@ -6310,7 +6310,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
ast_cli(fd, FORMAT, tmp->channel, tmp->exten, tmp->context, tmp->language, tmp->musicclass);
tmp = tmp->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -6327,7 +6327,7 @@ static int zap_show_channel(int fd, int argc, char **argv)
return RESULT_SHOWUSAGE;
channel = atoi(argv[3]);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
while (tmp) {
if (tmp->channel == channel) {
@@ -6392,14 +6392,14 @@ static int zap_show_channel(int fd, int argc, char **argv)
ast_cli(fd, "Actual Confmute: %s\n", x ? "Yes" : "No");
}
#endif
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
}
tmp = tmp->next;
}
ast_cli(fd, "Unable to find given channel %d\n", channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_FAILURE;
}
@@ -6457,7 +6457,7 @@ int load_module()
}
- 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;
@@ -6469,7 +6469,7 @@ int load_module()
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
@@ -6486,7 +6486,7 @@ int load_module()
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
@@ -6504,7 +6504,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;
}
@@ -6738,7 +6738,7 @@ int load_module()
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
@@ -6755,7 +6755,7 @@ int load_module()
ast_log(LOG_WARNING, "Ignoring %s\n", v->name);
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Make sure we can register our Zap channel type */
if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -6814,7 +6814,7 @@ int unload_module()
ast_cli_unregister(&cli_show_channels);
ast_cli_unregister(&cli_show_channel);
ast_cli_unregister(&cli_destroy_channel);
- if (!ast_pthread_mutex_lock(&iflock)) {
+ if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
@@ -6823,25 +6823,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) {
@@ -6857,7 +6857,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;
@@ -6937,7 +6937,7 @@ static int reload_zt(void)
}
- 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;
@@ -6959,7 +6959,7 @@ static int reload_zt(void)
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
stringp=v->value;
@@ -6973,7 +6973,7 @@ static int reload_zt(void)
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
if (finish < start) {
@@ -6990,7 +6990,7 @@ static int reload_zt(void)
} 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);
return -1;
}
}
@@ -7094,7 +7094,7 @@ static int reload_zt(void)
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
} else if (!strcasecmp(v->name, "minunused")) {
@@ -7116,7 +7116,7 @@ static int reload_zt(void)
if (tmp->destroy) {
if (destroy_channel(prev, tmp, 0)) {
ast_log(LOG_ERROR, "Unable to destroy chan_zap channel %d\n", tmp->channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
tmp = tmp->next;
@@ -7126,7 +7126,7 @@ static int reload_zt(void)
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
ast_destroy(cfg);
#if 0
@@ -7270,9 +7270,9 @@ int reload(void)
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;
}
diff --git a/channels/chan_zap_old.c b/channels/chan_zap_old.c
index 79324cadf..c81b6e5c6 100755
--- a/channels/chan_zap_old.c
+++ b/channels/chan_zap_old.c
@@ -188,14 +188,14 @@ static int gendigittimeout = 8000;
static int matchdigittimeout = 3000;
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 zt_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. */
@@ -245,7 +245,7 @@ static int r2prot = -1;
#ifdef ZAPATA_PRI
struct zt_pri {
pthread_t master; /* Thread of master */
- pthread_mutex_t lock; /* Mutex */
+ ast_mutex_t lock; /* Mutex */
char idleext[AST_MAX_EXTENSION]; /* Where to idle extra calls */
char idlecontext[AST_MAX_EXTENSION]; /* What context to use for idle */
char idledial[AST_MAX_EXTENSION]; /* What to dial before dumping */
@@ -285,7 +285,7 @@ static inline int pri_grab(struct zt_pri *pri)
{
int res;
/* Grab the lock first */
- res = ast_pthread_mutex_lock(&pri->lock);
+ res = ast_mutex_lock(&pri->lock);
if (res)
return res;
/* Then break the select */
@@ -295,7 +295,7 @@ static inline int pri_grab(struct zt_pri *pri)
static inline void pri_rel(struct zt_pri *pri)
{
- ast_pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
static int switchtype = PRI_SWITCH_NI2;
@@ -334,7 +334,7 @@ struct zt_subchannel {
#define MAX_SLAVES 4
static struct zt_pvt {
- pthread_mutex_t lock;
+ ast_mutex_t lock;
struct ast_channel *owner; /* Our current active owner (if applicable) */
/* Up to three channels can be associated with this call */
@@ -1502,16 +1502,16 @@ static int zt_hangup(struct ast_channel *ast)
p->callwaitingrepeat = 0;
ast->pvt->pvt = NULL;
ast_setstate(ast, AST_STATE_DOWN);
- 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);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
prev = NULL;
if (p->destroy) {
@@ -1525,7 +1525,7 @@ static int zt_hangup(struct ast_channel *ast)
}
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return 0;
}
@@ -1809,8 +1809,8 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
/* cant do pseudo-channels here */
if ((!p0->sig) || (!p1->sig)) return -2;
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
op0 = p0 = c0->pvt->pvt;
op1 = p1 = c1->pvt->pvt;
ofd1 = c0->fds[0];
@@ -1824,12 +1824,12 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
- ast_pthread_mutex_lock(&p0->lock);
- if (pthread_mutex_trylock(&p1->lock)) {
+ ast_mutex_lock(&p0->lock);
+ if (ast_mutex_trylock(&p1->lock)) {
/* Don't block, due to potential for deadlock */
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
return -3;
}
@@ -1923,11 +1923,11 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
t1 = p0->subs[SUB_REAL].inthreeway;
t2 = p1->subs[SUB_REAL].inthreeway;
- ast_pthread_mutex_unlock(&p0->lock);
- ast_pthread_mutex_unlock(&p1->lock);
+ ast_mutex_unlock(&p0->lock);
+ ast_mutex_unlock(&p1->lock);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
/* Native bridge failed */
if ((!master || !slave) && !nothingok)
@@ -1939,16 +1939,16 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
for (;;) {
/* Here's our main loop... Start by locking things, looking for private parts,
and then balking if anything is wrong */
- ast_pthread_mutex_lock(&c0->lock);
- ast_pthread_mutex_lock(&c1->lock);
+ ast_mutex_lock(&c0->lock);
+ ast_mutex_lock(&c1->lock);
p0 = c0->pvt->pvt;
p1 = c1->pvt->pvt;
if (op0 == p0)
i1 = zt_get_index(c0, p0, 1);
if (op1 == p1)
i2 = zt_get_index(c1, p1, 1);
- ast_pthread_mutex_unlock(&c0->lock);
- ast_pthread_mutex_unlock(&c1->lock);
+ ast_mutex_unlock(&c0->lock);
+ ast_mutex_unlock(&c1->lock);
if ((op0 != p0) || (op1 != p1) ||
(ofd1 != c0->fds[0]) ||
(ofd2 != c1->fds[0]) ||
@@ -2709,7 +2709,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
struct ast_frame *f;
- ast_pthread_mutex_lock(&p->lock);
+ ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 0);
@@ -2725,7 +2725,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
/* Hang up if we don't really exist */
if (index < 0) {
ast_log(LOG_WARNING, "We dont exist?\n");
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
@@ -2747,11 +2747,11 @@ struct ast_frame *zt_read(struct ast_channel *ast)
{
p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
if (p->ringt == 1) {
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
else if (p->ringt > 0)
@@ -2763,7 +2763,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_RINGING;
ast_setstate(ast, AST_STATE_RINGING);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
@@ -2778,7 +2778,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
@@ -2822,7 +2822,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
@@ -2843,7 +2843,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
}
} else {
ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
@@ -2854,7 +2854,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
if (res < 0) {
if (res == -1)
ast_log(LOG_WARNING, "zt_rec: %s\n", strerror(errno));
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return NULL;
}
if (res != READ_SIZE) {
@@ -2884,7 +2884,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
}
p->callwaitcas = 0;
/* Return NULL */
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
} else {
strncpy(p->subs[index].dtmfq + strlen(p->subs[index].dtmfq), zap_dtmfbuf(p->subs[index].z), sizeof(p->subs[index].dtmfq) - strlen(p->subs[index].dtmfq)-1);
@@ -2892,7 +2892,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
}
}
} else {
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return zt_handle_event(ast);
}
if (strlen(p->subs[index].dtmfq)) {
@@ -2916,12 +2916,12 @@ struct ast_frame *zt_read(struct ast_channel *ast)
ast_log(LOG_DEBUG, "Fax already handled\n");
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
p->subs[index].f.frametype = AST_FRAME_DTMF;
}
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
if (p->tdd) { /* if in TDD mode, see if we receive that */
@@ -2940,7 +2940,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET;
p->subs[index].f.datalen = 1;
*((char *) p->subs[index].f.data) = c;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return &p->subs[index].f;
}
}
@@ -2998,7 +2998,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
}
} else
f = &p->subs[index].f;
- pthread_mutex_unlock(&p->lock);
+ ast_mutex_unlock(&p->lock);
return f;
}
@@ -3240,9 +3240,9 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
}
i->subs[index].owner = tmp;
ast_setstate(tmp, state);
- 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);
/* Copy call forward info */
@@ -4018,7 +4018,7 @@ static void *do_monitor(void *data)
#endif
for(;;) {
/* 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");
return NULL;
}
@@ -4049,7 +4049,7 @@ 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);
pthread_testcancel();
/* Wait at least a second for something to happen */
@@ -4065,7 +4065,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;
}
@@ -4183,7 +4183,7 @@ static void *do_monitor(void *data)
}
i=i->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
}
/* Never reached */
return NULL;
@@ -4198,12 +4198,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;
}
@@ -4219,7 +4219,7 @@ static int restart_monitor(void)
} else {
/* Start a new monitor */
if (pthread_create(&monitor_thread, &attr, 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;
}
@@ -4227,7 +4227,7 @@ static int restart_monitor(void)
#if 0
printf("Created thread %ld detached in restart monitor\n", monitor_thread);
#endif
- ast_pthread_mutex_unlock(&monlock);
+ ast_mutex_unlock(&monlock);
return 0;
}
@@ -4729,7 +4729,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
channelmatch = x;
}
/* 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;
}
@@ -4788,7 +4788,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
}
p = p->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
restart_monitor();
return tmp;
}
@@ -4992,7 +4992,7 @@ static void *pri_dchannel(void *vpri)
FD_SET(pri->fd, &rfds);
FD_SET(pri->fd, &efds);
time(&t);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (pri->resetting && pri->up) {
/* Look for a resetable channel and go */
if ((t - pri->lastreset) > 0) {
@@ -5111,12 +5111,12 @@ static void *pri_dchannel(void *vpri)
tv.tv_sec = 60;
tv.tv_usec = 0;
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
e = NULL;
res = ast_select(pri->fd + 1, &rfds, NULL, &efds, &tv);
- ast_pthread_mutex_lock(&pri->lock);
+ ast_mutex_lock(&pri->lock);
if (!res) {
/* Just a timeout, run the scheduler */
e = pri_schedule_run(pri->pri);
@@ -5421,7 +5421,7 @@ static void *pri_dchannel(void *vpri)
if (option_debug)
ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
}
- pthread_mutex_unlock(&pri->lock);
+ ast_mutex_unlock(&pri->lock);
}
/* Never reached */
return NULL;
@@ -5690,7 +5690,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
ast_cli(fd, FORMAT2, "Chan. Num.", "Extension", "Context", "Language", "MusicOnHold");
tmp = iflist;
@@ -5698,7 +5698,7 @@ static int zap_show_channels(int fd, int argc, char **argv)
ast_cli(fd, FORMAT, tmp->channel, tmp->exten, tmp->context, tmp->language, tmp->musicclass);
tmp = tmp->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -5714,7 +5714,7 @@ static int zap_show_channel(int fd, int argc, char **argv)
return RESULT_SHOWUSAGE;
channel = atoi(argv[3]);
- ast_pthread_mutex_lock(&iflock);
+ ast_mutex_lock(&iflock);
tmp = iflist;
while (tmp) {
if (tmp->channel == channel) {
@@ -5764,14 +5764,14 @@ static int zap_show_channel(int fd, int argc, char **argv)
ast_cli(fd, "\n");
}
#endif
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_SUCCESS;
}
tmp = tmp->next;
}
ast_cli(fd, "Unable to find given channel %d\n", channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return RESULT_FAILURE;
}
@@ -5829,7 +5829,7 @@ int load_module()
}
- 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;
@@ -5841,7 +5841,7 @@ int load_module()
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
@@ -5858,7 +5858,7 @@ int load_module()
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
@@ -5876,7 +5876,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;
}
@@ -6066,7 +6066,7 @@ int load_module()
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
unload_module();
return -1;
}
@@ -6081,7 +6081,7 @@ int load_module()
ast_log(LOG_DEBUG, "Ignoring %s\n", v->name);
v = v->next;
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
/* Make sure we can register our Zap channel type */
if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -6140,7 +6140,7 @@ int unload_module()
ast_cli_unregister(&cli_show_channels);
ast_cli_unregister(&cli_show_channel);
ast_cli_unregister(&cli_destroy_channel);
- if (!ast_pthread_mutex_lock(&iflock)) {
+ if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
while(p) {
@@ -6149,25 +6149,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) {
@@ -6183,7 +6183,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;
@@ -6262,7 +6262,7 @@ static int reload_zt(void)
}
- 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;
@@ -6284,7 +6284,7 @@ static int reload_zt(void)
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
stringp=v->value;
@@ -6298,7 +6298,7 @@ static int reload_zt(void)
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
if (finish < start) {
@@ -6315,7 +6315,7 @@ static int reload_zt(void)
} 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);
return -1;
}
}
@@ -6417,7 +6417,7 @@ static int reload_zt(void)
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
} else if (!strcasecmp(v->name, "minunused")) {
@@ -6439,7 +6439,7 @@ static int reload_zt(void)
if (tmp->destroy) {
if (destroy_channel(prev, tmp, 0)) {
ast_log(LOG_ERROR, "Unable to destroy chan_zap channel %d\n", tmp->channel);
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
return -1;
}
tmp = tmp->next;
@@ -6449,7 +6449,7 @@ static int reload_zt(void)
}
}
- ast_pthread_mutex_unlock(&iflock);
+ ast_mutex_unlock(&iflock);
ast_destroy(cfg);
#if 0
@@ -6593,9 +6593,9 @@ int reload(void)
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;
}