Fix deadlock in iax
authorMartin Pycko <martinp@digium.com>
Thu, 13 Nov 2003 23:49:15 +0000 (23:49 +0000)
committerMartin Pycko <martinp@digium.com>
Thu, 13 Nov 2003 23:49:15 +0000 (23:49 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1745 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax.c

index ce36153..231eec5 100755 (executable)
@@ -3774,7 +3774,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
                                        ast_log(LOG_DEBUG, "Ooh, voice format changed to %s\n", ast_getformatname(f.subclass));
                                        if (iaxs[fr.callno]->owner) {
                                                int orignative;
                                        ast_log(LOG_DEBUG, "Ooh, voice format changed to %s\n", ast_getformatname(f.subclass));
                                        if (iaxs[fr.callno]->owner) {
                                                int orignative;
-                                               ast_mutex_lock(&iaxs[fr.callno]->owner->lock);
+retryowner:
+                                               if (ast_mutex_trylock(&iaxs[fr.callno]->owner->lock)) {
+                                                       ast_mutex_unlock(&iaxsl[fr.callno]);
+                                                       usleep(1);
+                                                       ast_mutex_lock(&iaxsl[fr.callno]);
+                                                       if (iaxs[fr.callno] && iaxs[fr.callno]->owner) goto retryowner;
+                                               }
                                                orignative = iaxs[fr.callno]->owner->nativeformats;
                                                iaxs[fr.callno]->owner->nativeformats = f.subclass;
                                                if (iaxs[fr.callno]->owner->readformat)
                                                orignative = iaxs[fr.callno]->owner->nativeformats;
                                                iaxs[fr.callno]->owner->nativeformats = f.subclass;
                                                if (iaxs[fr.callno]->owner->readformat)