[asterisk-commits] branch russell/hold_handling r37827 - in
/team/russell/hold_handling: ./ chan...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Jul 17 16:22:26 MST 2006
Author: russell
Date: Mon Jul 17 18:22:25 2006
New Revision: 37827
URL: http://svn.digium.com/view/asterisk?rev=37827&view=rev
Log:
fix various breakage ...
- include the terminating null char in the datalen for control frame payloads
- fix some issues with ast_frdup() when the original frame's data is null
Modified:
team/russell/hold_handling/channels/chan_agent.c
team/russell/hold_handling/channels/chan_iax2.c
team/russell/hold_handling/channels/chan_mgcp.c
team/russell/hold_handling/channels/chan_sip.c
team/russell/hold_handling/channels/chan_zap.c
team/russell/hold_handling/frame.c
team/russell/hold_handling/res/res_features.c
Modified: team/russell/hold_handling/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/russell/hold_handling/channels/chan_agent.c?rev=37827&r1=37826&r2=37827&view=diff
==============================================================================
--- team/russell/hold_handling/channels/chan_agent.c (original)
+++ team/russell/hold_handling/channels/chan_agent.c Mon Jul 17 18:22:25 2006
@@ -773,7 +773,9 @@
ast_channel_unlock(p->chan);
} else if (p->loginstart) {
ast_channel_lock(p->chan);
- ast_indicate_data(p->chan, AST_CONTROL_HOLD, p->moh, strlen(p->moh));
+ ast_indicate_data(p->chan, AST_CONTROL_HOLD,
+ S_OR(p->moh, NULL),
+ !ast_strlen_zero(p->moh) ? strlen(p->moh) + 1 : 0);
ast_channel_unlock(p->chan);
}
}
@@ -1964,7 +1966,9 @@
res = ast_safe_sleep(chan, 500);
ast_mutex_unlock(&p->lock);
} else if (!res) {
- ast_indicate_data(chan, AST_CONTROL_HOLD, p->moh, strlen(p->moh));
+ ast_indicate_data(chan, AST_CONTROL_HOLD,
+ S_OR(p->moh, NULL),
+ !ast_strlen_zero(p->moh) ? strlen(p->moh) + 1 : 0);
if (p->loginstart == 0)
time(&p->loginstart);
manager_event(EVENT_FLAG_AGENT, "Agentlogin",
Modified: team/russell/hold_handling/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/hold_handling/channels/chan_iax2.c?rev=37827&r1=37826&r2=37827&view=diff
==============================================================================
--- team/russell/hold_handling/channels/chan_iax2.c (original)
+++ team/russell/hold_handling/channels/chan_iax2.c Mon Jul 17 18:22:25 2006
@@ -6706,7 +6706,8 @@
if (iaxs[fr->callno]->owner && ast_bridged_channel(iaxs[fr->callno]->owner)) {
const char *mohsuggest = iaxs[fr->callno]->mohsuggest;
ast_queue_control_data(iaxs[fr->callno]->owner, AST_CONTROL_HOLD,
- !ast_strlen_zero(mohsuggest) ? mohsuggest : NULL, strlen(mohsuggest));
+ S_OR(mohsuggest, NULL),
+ !ast_strlen_zero(mohsuggest) ? strlen(mohsuggest) + 1 : 0);
}
}
}
Modified: team/russell/hold_handling/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/russell/hold_handling/channels/chan_mgcp.c?rev=37827&r1=37826&r2=37827&view=diff
==============================================================================
--- team/russell/hold_handling/channels/chan_mgcp.c (original)
+++ team/russell/hold_handling/channels/chan_mgcp.c Mon Jul 17 18:22:25 2006
@@ -3091,7 +3091,7 @@
ast_queue_control(sub->owner, AST_CONTROL_HOLD);
if (ast_bridged_channel(sub->next->owner))
- ast_queue_control_data(sub->next->owner, AST_CONTROL_HOLD, NULL, 0);
+ ast_queue_control(sub->next->owner, AST_CONTROL_HOLD);
handle_hd_hf(sub->next, ev);
}
Modified: team/russell/hold_handling/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/hold_handling/channels/chan_sip.c?rev=37827&r1=37826&r2=37827&view=diff
==============================================================================
--- team/russell/hold_handling/channels/chan_sip.c (original)
+++ team/russell/hold_handling/channels/chan_sip.c Mon Jul 17 18:22:25 2006
@@ -4942,7 +4942,8 @@
} else if (!sin.sin_addr.s_addr || sendonly) {
/* No address for RTP, we're on hold */
ast_queue_control_data(p->owner, AST_CONTROL_HOLD,
- !ast_strlen_zero(p->mohsuggest) ? p->mohsuggest : NULL, strlen(p->mohsuggest));
+ S_OR(p->mohsuggest, NULL),
+ !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
if (sendonly)
ast_rtp_stop(p->rtp);
Modified: team/russell/hold_handling/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/hold_handling/channels/chan_zap.c?rev=37827&r1=37826&r2=37827&view=diff
==============================================================================
--- team/russell/hold_handling/channels/chan_zap.c (original)
+++ team/russell/hold_handling/channels/chan_zap.c Mon Jul 17 18:22:25 2006
@@ -2449,7 +2449,8 @@
on music on hold now */
if (p->subs[SUB_THREEWAY].owner && ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
- !ast_strlen_zero(p->mohsuggest) ? p->mohsuggest : NULL, strlen(p->mohsuggest));
+ S_OR(p->mohsuggest, NULL),
+ !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
}
p->subs[SUB_THREEWAY].inthreeway = 0;
/* Make it the call wait now */
@@ -2463,7 +2464,8 @@
Start music on hold for them, and take the main guy out of the third call */
if (p->subs[SUB_CALLWAIT].owner && ast_bridged_channel(p->subs[SUB_CALLWAIT].owner)) {
ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
- !ast_strlen_zero(p->mohsuggest) ? p->mohsuggest : NULL, strlen(p->mohsuggest));
+ S_OR(p->mohsuggest, NULL),
+ !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
}
p->subs[SUB_CALLWAIT].inthreeway = 0;
}
@@ -4061,12 +4063,14 @@
/* Start music on hold if appropriate */
if (!p->subs[SUB_CALLWAIT].inthreeway && ast_bridged_channel(p->subs[SUB_CALLWAIT].owner)) {
ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
- !ast_strlen_zero(p->mohsuggest) ? p->mohsuggest : NULL, strlen(p->mohsuggest));
+ S_OR(p->mohsuggest, NULL),
+ !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
}
p->subs[SUB_CALLWAIT].needhold = 1;
if (ast_bridged_channel(p->subs[SUB_REAL].owner)) {
ast_queue_control_data(p->subs[SUB_REAL].owner, AST_CONTROL_HOLD,
- !ast_strlen_zero(p->mohsuggest) ? p->mohsuggest : NULL, strlen(p->mohsuggest));
+ S_OR(p->mohsuggest, NULL),
+ !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
}
p->subs[SUB_REAL].needunhold = 1;
} else if (!p->subs[SUB_THREEWAY].owner) {
@@ -4127,7 +4131,8 @@
/* Start music on hold if appropriate */
if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
- !ast_strlen_zero(p->mohsuggest) ? p->mohsuggest : NULL, strlen(p->mohsuggest));
+ S_OR(p->mohsuggest, NULL),
+ !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
}
p->subs[SUB_THREEWAY].needhold = 1;
}
Modified: team/russell/hold_handling/frame.c
URL: http://svn.digium.com/view/asterisk/team/russell/hold_handling/frame.c?rev=37827&r1=37826&r2=37827&view=diff
==============================================================================
--- team/russell/hold_handling/frame.c (original)
+++ team/russell/hold_handling/frame.c Mon Jul 17 18:22:25 2006
@@ -375,7 +375,7 @@
srclen = strlen(f->src);
if (srclen > 0)
len += srclen + 1;
- if (!(buf = ast_malloc(len)))
+ if (!(buf = ast_calloc(1, len)))
return NULL;
out = buf;
/* Set us as having malloc'd header only, so it will eventually
@@ -387,16 +387,15 @@
out->delivery = f->delivery;
out->mallocd = AST_MALLOCD_HDR;
out->offset = AST_FRIENDLY_OFFSET;
- out->data = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
+ if (out->datalen) {
+ out->data = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
+ memcpy(out->data, f->data, out->datalen);
+ }
if (srclen > 0) {
out->src = out->data + f->datalen;
/* Must have space since we allocated for it */
strcpy((char *)out->src, f->src);
- } else
- out->src = NULL;
- out->prev = NULL;
- out->next = NULL;
- memcpy(out->data, f->data, out->datalen);
+ }
out->has_timing_info = f->has_timing_info;
if (f->has_timing_info) {
out->ts = f->ts;
Modified: team/russell/hold_handling/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/russell/hold_handling/res/res_features.c?rev=37827&r1=37826&r2=37827&view=diff
==============================================================================
--- team/russell/hold_handling/res/res_features.c (original)
+++ team/russell/hold_handling/res/res_features.c Mon Jul 17 18:22:25 2006
@@ -362,7 +362,8 @@
/* Put the parked channel on hold if we have two different channels */
if (chan != peer) {
ast_indicate_data(pu->chan, AST_CONTROL_HOLD,
- !ast_strlen_zero(parkmohclass) ? parkmohclass : NULL, strlen(parkmohclass));
+ S_OR(parkmohclass, NULL),
+ !ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
}
pu->start = ast_tvnow();
@@ -426,7 +427,8 @@
if (pu->notquiteyet) {
/* Wake up parking thread if we're really done */
ast_indicate_data(pu->chan, AST_CONTROL_HOLD,
- !ast_strlen_zero(parkmohclass) ? parkmohclass : NULL, strlen(parkmohclass));
+ S_OR(parkmohclass, NULL),
+ !ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
pu->notquiteyet = 0;
pthread_kill(parking_thread, SIGURG);
}
@@ -1617,8 +1619,8 @@
if (option_debug)
ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting.\n");
ast_indicate_data(pu->chan, AST_CONTROL_HOLD,
- !ast_strlen_zero(parkmohclass) ? parkmohclass : NULL,
- strlen(parkmohclass));
+ S_OR(parkmohclass, NULL),
+ !ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
pu->moh_trys++;
}
goto std; /*! \todo XXX Ick: jumping into an else statement??? XXX */
More information about the asterisk-commits
mailing list