Fix crash in chanspy (bug #5332)
[asterisk/asterisk.git] / channel.c
index cf972e9..3218c8d 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -939,22 +939,14 @@ void ast_channel_free(struct ast_channel *chan)
 static void ast_spy_detach(struct ast_channel *chan) 
 {
        struct ast_channel_spy *chanspy;
-       int to=3000;
-       int sleepms = 100;
 
+       /* Marking the spies as done is sufficient.  Chanspy or spy users will get the picture. */
        for (chanspy = chan->spiers; chanspy; chanspy = chanspy->next) {
                if (chanspy->status == CHANSPY_RUNNING) {
                        chanspy->status = CHANSPY_DONE;
                }
        }
 
-       /* signal all the spys to get lost and allow them time to unhook themselves 
-          god help us if they don't......
-       */
-       while (chan->spiers && to >= 0) {
-               ast_safe_sleep(chan, sleepms);
-               to -= sleepms;
-       }
        chan->spiers = NULL;
        return;
 }