[svn-commits] mnicholson: trunk r926 - /trunk/channels/chan_mobile.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed May 27 12:07:04 CDT 2009
Author: mnicholson
Date: Wed May 27 12:07:00 2009
New Revision: 926
URL: http://svn.asterisk.org/svn-view/asterisk-addons?view=rev&rev=926
Log:
Lock the pvt structure in the mbl_read() and mbl_write() functions.
(issue #15075)
Reported by: hmld
Patches:
chan_mobile_v2.diff uploaded by zvision (license 798)
chan_mobile_v2a.diff uploaded by hmld (license 777)
Tested by: hmld, zvision, rseste
Modified:
trunk/channels/chan_mobile.c
Modified: trunk/channels/chan_mobile.c
URL: http://svn.asterisk.org/svn-view/asterisk-addons/trunk/channels/chan_mobile.c?view=diff&rev=926&r1=925&r2=926
==============================================================================
--- trunk/channels/chan_mobile.c (original)
+++ trunk/channels/chan_mobile.c Wed May 27 12:07:00 2009
@@ -1017,12 +1017,17 @@
{
struct mbl_pvt *pvt = ast->tech_pvt;
+ struct ast_frame *fr = &ast_null_frame;
int r;
ast_debug(3, "*** mbl_read()\n");
+ while (ast_mutex_trylock(&pvt->lock)) {
+ CHANNEL_DEADLOCK_AVOIDANCE(ast);
+ }
+
if (!pvt->owner) {
- return &ast_null_frame;
+ goto e_return;
}
memset(&pvt->fr, 0x00, sizeof(struct ast_frame));
pvt->fr.frametype = AST_FRAME_VOICE;
@@ -1036,7 +1041,7 @@
if ((r = read(pvt->sco_socket, pvt->fr.data.ptr, DEVICE_FRAME_SIZE)) == -1) {
ast_log(LOG_ERROR, "read error %d\n", errno);
- return &ast_null_frame;
+ goto e_return;
}
pvt->fr.datalen = r;
@@ -1045,8 +1050,15 @@
if (pvt->do_alignment_detection)
do_alignment_detection(pvt, pvt->fr.data.ptr, r);
- return ast_dsp_process(ast, pvt->dsp, &pvt->fr);
-
+ fr = ast_dsp_process(ast, pvt->dsp, &pvt->fr);
+
+ ast_mutex_unlock(&pvt->lock);
+
+ return fr;
+
+e_return:
+ ast_mutex_unlock(&pvt->lock);
+ return fr;
}
static int mbl_write(struct ast_channel *ast, struct ast_frame *frame)
@@ -1059,6 +1071,10 @@
if (frame->frametype != AST_FRAME_VOICE) {
return 0;
+ }
+
+ while (ast_mutex_trylock(&pvt->lock)) {
+ CHANNEL_DEADLOCK_AVOIDANCE(ast);
}
ast_smoother_feed(pvt->smoother, frame);
@@ -1067,6 +1083,8 @@
sco_write(pvt->sco_socket, f->data.ptr, f->datalen);
ast_frfree(f);
}
+
+ ast_mutex_unlock(&pvt->lock);
return 0;
More information about the svn-commits
mailing list