diff --git a/src/include/switch_event.h b/src/include/switch_event.h index bbb648df13..32094b5aec 100644 --- a/src/include/switch_event.h +++ b/src/include/switch_event.h @@ -332,6 +332,15 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char */ #define switch_event_create(event, id) switch_event_create_subclass(event, id, SWITCH_EVENT_SUBCLASS_ANY) +static inline switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id) +{ + switch_status_t status = switch_event_create(event, SWITCH_EVENT_CLONE); + if (status == SWITCH_STATUS_SUCCESS) { + (*event)->event_id = event_id; + } + + return status; +} /*! \brief Deliver an event to all of the registered event listeners \param event the event to send (will be nulled) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 2eb6b7f5a1..b09e52c094 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -938,7 +938,7 @@ SWITCH_STANDARD_APP(info_function) switch_event_t *event; char *buf; - if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { + if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(switch_core_session_get_channel(session), event); switch_event_serialize(event, &buf, SWITCH_FALSE); switch_assert(buf); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 4b01b682c6..4754a5b368 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1147,14 +1147,14 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) if (in) { if (!gateway->ib_vars) { - switch_event_create(&gateway->ib_vars, SWITCH_EVENT_GENERAL); + switch_event_create_plain(&gateway->ib_vars, SWITCH_EVENT_GENERAL); } switch_event_add_header_string(gateway->ib_vars, SWITCH_STACK_BOTTOM, var, val); } if (out) { if (!gateway->ob_vars) { - switch_event_create(&gateway->ob_vars, SWITCH_EVENT_GENERAL); + switch_event_create_plain(&gateway->ob_vars, SWITCH_EVENT_GENERAL); } switch_event_add_header_string(gateway->ob_vars, SWITCH_STACK_BOTTOM, var, val); } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 8ba631329f..b0cb856740 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1780,8 +1780,10 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co if (first && ret == AUTH_OK) { if (v_event) { - switch_event_create(v_event, SWITCH_EVENT_REQUEST_PARAMS); + switch_event_create_plain(v_event, SWITCH_EVENT_REQUEST_PARAMS); } + + if (v_event && *v_event) { switch_xml_t xparams[3]; int i = 0; diff --git a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c index 237800186f..b580da002b 100644 --- a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c +++ b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c @@ -199,7 +199,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) if (globals.debug) { switch_event_t *event; - if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { + if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { char *buf; switch_channel_event_set_data(channel, event); switch_event_serialize(event, &buf, SWITCH_FALSE); diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 40c5abfb15..8f2e2484ad 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -611,8 +611,7 @@ SWITCH_STANDARD_API(event_sink_function) switch_mutex_lock(listener->filter_mutex); if (!listener->filters) { - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } if (!strcasecmp(action, "delete")) { @@ -623,8 +622,7 @@ SWITCH_STANDARD_API(event_sink_function) if (!strcasecmp(header_val, "all")) { switch_event_destroy(&listener->filters); - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } else { switch_event_del_header(listener->filters, header_val); } @@ -1408,15 +1406,13 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even switch_mutex_lock(listener->filter_mutex); if (!listener->filters) { - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } if (!strcasecmp(header_name, "delete")) { if (!strcasecmp(header_val, "all")) { switch_event_destroy(&listener->filters); - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } else { switch_event_del_header(listener->filters, header_val); } diff --git a/src/switch_channel.c b/src/switch_channel.c index b6ed57115a..4195caec5e 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -220,7 +220,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, return SWITCH_STATUS_MEMERR; } - switch_event_create(&(*channel)->variables, SWITCH_EVENT_GENERAL); + switch_event_create_plain(&(*channel)->variables, SWITCH_EVENT_CHANNEL_DATA); switch_core_hash_init(&(*channel)->private_hash, pool); switch_queue_create(&(*channel)->dtmf_queue, SWITCH_DTMF_LOG_LEN, pool);