]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 369709 via svnmerge from
authorAutomerge script <automerge@asterisk.org>
Fri, 6 Jul 2012 16:23:13 +0000 (16:23 +0000)
committerAutomerge script <automerge@asterisk.org>
Fri, 6 Jul 2012 16:23:13 +0000 (16:23 +0000)
file:///srv/subversion/repos/asterisk/branches/10

................
  r369709 | mmichelson | 2012-07-06 10:23:28 -0500 (Fri, 06 Jul 2012) | 14 lines

  Fix bridging thread leak.

  The bridge thread was exiting but was never being
  reaped using pthread_join(). This has been fixed now
  by calling pthread_join() in ast_bridge_destroy().

  (closes issue ASTERISK-19834)
  Reported by Marcus Hunger

  Review: https://reviewboard.asterisk.org/r/2012
  ........

  Merged revisions 369708 from http://svn.asterisk.org/svn/asterisk/branches/1.8
................

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@369725 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/bridging.c

index b1d67f0e8ee2c2c1acb3a4cfd222455714cfcc92..a8b8d347ad88650dab2ea1cd7776718f7cb10847 100644 (file)
@@ -238,9 +238,6 @@ static void bridge_check_dissolve(struct ast_bridge *bridge, struct ast_bridge_c
                }
        }
 
-       /* Since all the channels are going away let's go ahead and stop our on thread */
-       bridge->stop = 1;
-
        return;
 }
 
@@ -540,9 +537,14 @@ int ast_bridge_destroy(struct ast_bridge *bridge)
 
        ao2_lock(bridge);
 
-       bridge->stop = 1;
-
-       bridge_poke(bridge);
+       if (bridge->thread != AST_PTHREADT_NULL) {
+               pthread_t thread = bridge->thread;
+               bridge->stop = 1;
+               bridge_poke(bridge);
+               ao2_unlock(bridge);
+               pthread_join(thread, NULL);
+               ao2_lock(bridge);
+       }
 
        ast_debug(1, "Telling all channels in bridge %p to end and leave the party\n", bridge);