diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-02-26 16:51:18 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-02-26 16:51:18 +0000 |
commit | db3a508c8e67375399c7d2aa58212431b3f71cdd (patch) | |
tree | b10a212d97a12b0153e99681d89d8e6400e71ab2 /channels/chan_iax2.c | |
parent | 41b46801d9000c1107af8f483c0f4a2bde32d417 (diff) |
Do more complete locking of the chan_iax2_pvt struct in the indicate callback.
(Problem brought up by Ben Smithurst on the asterisk-dev list)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@56785 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index bea3187be..9f7509ab4 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -3184,23 +3184,34 @@ static int iax2_answer(struct ast_channel *c) static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen) { unsigned short callno = PTR_TO_CALLNO(c->tech_pvt); + struct chan_iax2_pvt *pvt = c->tech_pvt; + int res = 0; if (option_debug && iaxdebug) ast_log(LOG_DEBUG, "Indicating condition %d\n", condition); - if (!strcasecmp(iaxs[callno]->mohinterpret, "passthrough")) - return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, data, datalen, -1); + ast_mutex_lock(&iaxsl[callno]); + + if (!strcasecmp(pvt->mohinterpret, "passthrough")) { + res = send_command(pvt, AST_FRAME_CONTROL, condition, 0, data, datalen, -1); + ast_mutex_unlock(&iaxsl[callno]); + return res; + } switch (condition) { case AST_CONTROL_HOLD: - ast_moh_start(c, data, iaxs[callno]->mohinterpret); - return 0; + ast_moh_start(c, data, pvt->mohinterpret); + break; case AST_CONTROL_UNHOLD: ast_moh_stop(c); - return 0; + break; default: - return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, data, datalen, -1); + res = send_command(pvt, AST_FRAME_CONTROL, condition, 0, data, datalen, -1); } + + ast_mutex_unlock(&iaxsl[callno]); + + return res; } static int iax2_transfer(struct ast_channel *c, const char *dest) |