aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channels/chan_iax2.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 5d924c3d9..8e80a0f9c 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -3553,9 +3553,41 @@ static int iax2_answer(struct ast_channel *c)
static int iax2_indicate(struct ast_channel *c, int condition)
{
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+ struct chan_iax2_pvt *pvt;
+ int res;
+
if (option_debug && iaxdebug)
ast_log(LOG_DEBUG, "Indicating condition %d\n", condition);
- return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, NULL, 0, -1);
+
+ ast_mutex_lock(&iaxsl[callno]);
+
+ pvt = iaxs[callno];
+
+ if (!pvt->peercallno) {
+ /* We don't know the remote side's call number, yet. :( */
+ int count = 10;
+ while (count-- && pvt && !pvt->peercallno) {
+ ast_mutex_unlock(&iaxsl[callno]);
+ usleep(1);
+ ast_mutex_lock(&iaxsl[callno]);
+ pvt = iaxs[callno];
+ }
+
+ if (!pvt->peercallno) {
+ /* Even after waiting, we still haven't completed a handshake with
+ * our peer, so we can't send this frame. Bail out. */
+ res = -1;
+ goto done;
+ }
+ }
+
+
+ res = send_command(iaxs[callno], AST_FRAME_CONTROL, condition, 0, NULL, 0, -1);
+
+done:
+ ast_mutex_unlock(&iaxsl[callno]);
+
+ return res;
}
static int iax2_transfer(struct ast_channel *c, const char *dest)