Fix deadlock potential with ast_set_hangupsource() calls.
[asterisk/asterisk.git] / channels / sig_analog.c
index 5d71696..cabb164 100644 (file)
@@ -3623,7 +3623,18 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast
                f = &p->subs[idx].f;
                return f;
        }
+
        f = __analog_handle_event(p, ast);
+       if (!f) {
+               const char *name = ast_strdupa(ast_channel_name(ast));
+
+               /* Tell the CDR this DAHDI device hung up */
+               analog_unlock_private(p);
+               ast_channel_unlock(ast);
+               ast_set_hangupsource(ast, name, 0);
+               ast_channel_lock(ast);
+               analog_lock_private(p);
+       }
        return f;
 }