[Asterisk-cvs] asterisk/channels chan_zap.c,1.210,1.211
markster at lists.digium.com
markster at lists.digium.com
Thu Apr 22 11:58:03 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv24541/channels
Modified Files:
chan_zap.c
Log Message:
Fix swap_subs for better locking
Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- chan_zap.c 22 Apr 2004 05:24:50 -0000 1.210
+++ chan_zap.c 22 Apr 2004 16:02:56 -0000 1.211
@@ -618,12 +618,29 @@
return res;
}
+static void wakeup_sub(struct zt_pvt *p, int a)
+{
+ struct ast_frame null = { AST_FRAME_NULL, };
+ for (;;) {
+ if (p->subs[a].owner) {
+ if (ast_mutex_trylock(&p->subs[a].owner->lock)) {
+ ast_mutex_unlock(&p->lock);
+ usleep(1);
+ ast_mutex_lock(&p->lock);
+ } else {
+ ast_queue_frame(p->subs[a].owner, &null);
+ ast_mutex_unlock(&p->subs[a].owner->lock);
+ }
+ } else
+ break;
+ }
+}
+
static void swap_subs(struct zt_pvt *p, int a, int b)
{
int tchan;
int tinthreeway;
struct ast_channel *towner;
- struct ast_frame null = { AST_FRAME_NULL, };
ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
@@ -639,15 +656,12 @@
p->subs[b].owner = towner;
p->subs[b].inthreeway = tinthreeway;
- if (p->subs[a].owner) {
+ if (p->subs[a].owner)
p->subs[a].owner->fds[0] = p->subs[a].zfd;
- ast_queue_frame(p->subs[a].owner, &null);
- }
- if (p->subs[b].owner) {
+ if (p->subs[b].owner)
p->subs[b].owner->fds[0] = p->subs[b].zfd;
- ast_queue_frame(p->subs[b].owner, &null);
- }
-
+ wakeup_sub(p, a);
+ wakeup_sub(p, b);
}
static int zt_open(char *fn)
More information about the svn-commits
mailing list