Multiple revisions 397921-397922
authorMark Michelson <mmichelson@digium.com>
Thu, 29 Aug 2013 15:43:23 +0000 (15:43 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 29 Aug 2013 15:43:23 +0000 (15:43 +0000)
........
  r397921 | mmichelson | 2013-08-29 10:42:10 -0500 (Thu, 29 Aug 2013) | 6 lines

  Resolve assumptions that bridge snapshots would be non-NULL for transfer stasis events.

  Attempting to transfer an unbridged call would result in crashes in either CEL code or
  in the conversion to AMI messages.
........
  r397922 | mmichelson | 2013-08-29 10:42:29 -0500 (Thu, 29 Aug 2013) | 3 lines

  Remove extra debug message.
........

Merged revisions 397921-397922 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397923 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_queue.c
main/cel.c
main/stasis_bridges.c

index 9471c6e..694527e 100644 (file)
@@ -5431,7 +5431,7 @@ static void handle_blind_transfer(void *userdata, struct stasis_subscription *su
                return;
        }
 
-       if (ast_json_integer_get(result_blob) == AST_BRIDGE_TRANSFER_FAIL) {
+       if (ast_json_integer_get(result_blob) != AST_BRIDGE_TRANSFER_SUCCESS) {
                return;
        }
 
@@ -5490,7 +5490,7 @@ static void handle_attended_transfer(void *userdata, struct stasis_subscription
                return;
        }
 
-       if (atxfer_msg->result == AST_BRIDGE_TRANSFER_FAIL ||
+       if (atxfer_msg->result != AST_BRIDGE_TRANSFER_SUCCESS ||
                        atxfer_msg->dest_type == AST_ATTENDED_TRANSFER_DEST_THREEWAY) {
                return;
        }
index e063fab..c4b80b5 100644 (file)
@@ -1197,10 +1197,24 @@ static void cel_blind_transfer_cb(
        struct ast_channel_snapshot *chan_snapshot = obj->channel;
        struct ast_bridge_snapshot *bridge_snapshot = obj->bridge;
        struct ast_json *blob = obj->blob;
-       struct ast_json *json_exten = ast_json_object_get(blob, "exten");
-       struct ast_json *json_context = ast_json_object_get(blob, "context");
+       struct ast_json *json_result = ast_json_object_get(blob, "result");
+       struct ast_json *json_exten;
+       struct ast_json *json_context;
        RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
        const char *exten, *context;
+       enum ast_transfer_result result;
+
+       if (!json_result) {
+               return;
+       }
+
+       result = ast_json_integer_get(json_result);
+       if (result != AST_BRIDGE_TRANSFER_SUCCESS) {
+               return;
+       }
+
+       json_exten = ast_json_object_get(blob, "exten");
+       json_context = ast_json_object_get(blob, "context");
 
        if (!json_exten || !json_context) {
                return;
@@ -1211,6 +1225,7 @@ static void cel_blind_transfer_cb(
        if (!exten || !context) {
                return;
        }
+
        extra = ast_json_pack("{s: s, s: s, s: s}",
                "extension", exten,
                "context", context,
index be1294a..0ff9cca 100644 (file)
@@ -585,11 +585,17 @@ static struct ast_manager_event_blob *blind_transfer_to_ami(struct stasis_messag
        }
 
        channel_state = ast_manager_build_channel_state_string_prefix(blob->channel, "Transferer");
-       bridge_state = ast_manager_build_bridge_state_string(blob->bridge);
-       if (!channel_state || !bridge_state) {
+       if (!channel_state) {
                return NULL;
        }
 
+       if (blob->bridge) {
+               bridge_state = ast_manager_build_bridge_state_string(blob->bridge);
+               if (!bridge_state) {
+                       return NULL;
+               }
+       }
+
        exten = ast_json_string_get(ast_json_object_get(blob->blob, "exten"));
        context = ast_json_string_get(ast_json_object_get(blob->blob, "context"));
        result = ast_json_integer_get(ast_json_object_get(blob->blob, "result"));
@@ -604,7 +610,7 @@ static struct ast_manager_event_blob *blind_transfer_to_ami(struct stasis_messag
                        "Extension: %s\r\n",
                        result_strs[result],
                        ast_str_buffer(channel_state),
-                       ast_str_buffer(bridge_state),
+                       bridge_state ? ast_str_buffer(bridge_state) : "",
                        is_external ? "Yes" : "No",
                        context,
                        exten);