diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-04 20:49:33 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-04 20:49:33 +0000 |
commit | e0334b13830b5ef5e0c5c378db781a959a32203c (patch) | |
tree | 3e30e857242e638cec5c32801071288b354dfb91 /channels | |
parent | ab21249208afe354dd609a6de738ba6c9992e288 (diff) |
On busy systems, it's possible for the values checked within a single line
of code to change, unless the structure is locked to ensure a consistent
state.
(closes issue #13717)
Reported by: kowalma
Patches:
20081102__bug13717.diff.txt uploaded by Corydon76 (license 14)
Tested by: kowalma
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@154365 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_iax2.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index cdda03ad7..1c3838ef8 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1558,12 +1558,21 @@ static int __find_callno(unsigned short callno, unsigned short dcallno, struct s /* This will occur on the first response to a message that we initiated, * such as a PING. */ + if (dcallno) { + ast_mutex_lock(&iaxsl[dcallno]); + } if (callno && dcallno && iaxs[dcallno] && !iaxs[dcallno]->peercallno && match(sin, callno, dcallno, iaxs[dcallno], check_dcallno)) { iaxs[dcallno]->peercallno = callno; res = dcallno; store_by_peercallno(iaxs[dcallno]); + if (!res || !return_locked) { + ast_mutex_unlock(&iaxsl[dcallno]); + } return res; } + if (dcallno) { + ast_mutex_unlock(&iaxsl[dcallno]); + } #ifdef IAX_OLD_FIND /* If we get here, we SHOULD NOT find a call structure for this |