aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authorcitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-27 07:34:37 +0000
committercitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-27 07:34:37 +0000
commit40646976f71b9598f3aaf3fa6b5ee642fb1924cd (patch)
tree8fb63a5adf8ae4381ad7d033befd4d8b3a708f51 /channel.c
parent5acf40987d242dc3f7c9329b8b9b61b3e512113a (diff)
Fixup read/write locking
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2573 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/channel.c b/channel.c
index 4c46e7017..0abc3521e 100755
--- a/channel.c
+++ b/channel.c
@@ -1505,7 +1505,8 @@ int ast_set_write_format(struct ast_channel *chan, int fmts, int needlock)
int native;
int res;
- ast_mutex_lock(&chan->lock);
+ if (needlock)
+ ast_mutex_lock(&chan->lock);
native = chan->nativeformats;
fmt = fmts;
@@ -1513,7 +1514,8 @@ int ast_set_write_format(struct ast_channel *chan, int fmts, int needlock)
if (res < 0) {
ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
ast_getformatname(fmts), ast_getformatname(chan->nativeformats));
- ast_mutex_unlock(&chan->lock);
+ if (needlock)
+ ast_mutex_unlock(&chan->lock);
return -1;
}
@@ -1528,7 +1530,8 @@ int ast_set_write_format(struct ast_channel *chan, int fmts, int needlock)
chan->pvt->writetrans = ast_translator_build_path(chan->pvt->rawwriteformat, chan->writeformat);
if (option_debug)
ast_log(LOG_DEBUG, "Set channel %s to write format %s\n", chan->name, ast_getformatname(chan->writeformat));
- ast_mutex_unlock(&chan->lock);
+ if (needlock)
+ ast_mutex_unlock(&chan->lock);
return 0;
}
@@ -1547,7 +1550,8 @@ int ast_set_read_format(struct ast_channel *chan, int fmts, int needlock)
if (res < 0) {
ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
ast_getformatname(chan->nativeformats), ast_getformatname(fmts));
- ast_mutex_unlock(&chan->lock);
+ if (needlock)
+ ast_mutex_unlock(&chan->lock);
return -1;
}
@@ -1563,7 +1567,8 @@ int ast_set_read_format(struct ast_channel *chan, int fmts, int needlock)
if (option_debug)
ast_log(LOG_DEBUG, "Set channel %s to read format %s\n",
chan->name, ast_getformatname(chan->readformat));
- ast_mutex_unlock(&chan->lock);
+ if (needlock)
+ ast_mutex_unlock(&chan->lock);
return 0;
}