stasis/control: Fix possible deadlock with swap channel
[asterisk/asterisk.git] / main / bridge_after.c
index d4aec75..69c8f98 100644 (file)
@@ -293,23 +293,23 @@ int ast_bridge_set_after_callback(struct ast_channel *chan, ast_bridge_after_cb
        return 0;
 }
 
-const char *reason_strings[] = {
-       [AST_BRIDGE_AFTER_CB_REASON_DESTROY] = "Channel destroyed (hungup)",
-       [AST_BRIDGE_AFTER_CB_REASON_REPLACED] = "Callback was replaced",
-       [AST_BRIDGE_AFTER_CB_REASON_MASQUERADE] = "Channel masqueraded",
-       [AST_BRIDGE_AFTER_CB_REASON_DEPART] = "Channel was departed from bridge",
-       [AST_BRIDGE_AFTER_CB_REASON_REMOVED] = "Callback was removed",
-};
-
 const char *ast_bridge_after_cb_reason_string(enum ast_bridge_after_cb_reason reason)
 {
-       if (reason < AST_BRIDGE_AFTER_CB_REASON_DESTROY
-               || AST_BRIDGE_AFTER_CB_REASON_REMOVED < reason
-               || !reason_strings[reason]) {
-               return "Unknown";
-       }
-
-       return reason_strings[reason];
+       switch (reason) {
+       case AST_BRIDGE_AFTER_CB_REASON_DESTROY:
+               return "Channel destroyed (hungup)";
+       case AST_BRIDGE_AFTER_CB_REASON_REPLACED:
+               return "Callback was replaced";
+       case AST_BRIDGE_AFTER_CB_REASON_MASQUERADE:
+               return "Channel masqueraded";
+       case AST_BRIDGE_AFTER_CB_REASON_DEPART:
+               return "Channel was departed from bridge";
+       case AST_BRIDGE_AFTER_CB_REASON_REMOVED:
+               return "Callback was removed";
+       case AST_BRIDGE_AFTER_CB_REASON_IMPART_FAILED:
+               return "Channel failed joining the bridge";
+       }
+       return "Unknown";
 }
 
 struct after_bridge_goto_ds {