diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 6bf811e2046117b2f7988c085c333c8530d4967c..1eb018af0c4a34854eec31a570d2683c39999c1a 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1507,7 +1507,8 @@ static int __find_callno(unsigned short callno, unsigned short dcallno, struct s res = x; } } - ast_mutex_unlock(&iaxsl[x]); + if (res && !return_locked) + ast_mutex_unlock(&iaxsl[x]); } for (x=TRUNK_CALL_START;(res < 1) && (x<maxtrunkcall);x++) { ast_mutex_lock(&iaxsl[x]); @@ -1517,7 +1518,8 @@ static int __find_callno(unsigned short callno, unsigned short dcallno, struct s res = x; } } - ast_mutex_unlock(&iaxsl[x]); + if (res && !return_locked) + ast_mutex_unlock(&iaxsl[x]); } } if ((res < 1) && (new >= NEW_ALLOW)) {