\param endpoint_name the name of the module to use for the new session
\param caller_profile the originator's caller profile
\param new_session a NULL pointer to aim at the newly created session
+ \param pool optional existing memory pool to donate to the session (WILL BE KEPT)
\return SWITCH_STATUS_SUCCESS if the session was created
+ \note if the pool arguement is not null the pool will be adopted by the session and your pointer will be nulled
*/
SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_session *session,
- char *endpoint_name,
- switch_caller_profile *caller_profile,
- switch_core_session **new_session);
+ char *endpoint_name,
+ switch_caller_profile *caller_profile,
+ switch_core_session **new_session,
+ switch_memory_pool **pool);
/*!
\brief Answer the channel of a given session
/*! \brief A table of i/o routines that an endpoint interface can implement */
struct switch_io_routines {
/*! creates an outgoing session from given session, caller profile */
- switch_status (*outgoing_channel)(switch_core_session *, switch_caller_profile *, switch_core_session **);
+ switch_status (*outgoing_channel)(switch_core_session *, switch_caller_profile *, switch_core_session **, switch_memory_pool *);
/*! answers the given session's channel */
switch_status (*answer_channel)(switch_core_session *);
/*! read a frame from a session */
- if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session) !=
+ if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session, NULL) !=
SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Create Outgoing Channel!\n");
switch_channel_hangup(caller_channel);
static switch_status exosip_on_loopback(switch_core_session *session);
static switch_status exosip_on_transmit(switch_core_session *session);
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session);
+ switch_core_session **new_session, switch_memory_pool *pool);
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
switch_io_flag flags, int stream_id);
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
};
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session)
+ switch_core_session **new_session, switch_memory_pool *pool)
{
- if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) {
+ if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, pool)) != 0) {
struct private_object *tech_pvt;
switch_channel *channel;
static switch_status channel_on_loopback(switch_core_session *session);
static switch_status channel_on_transmit(switch_core_session *session);
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session);
+ switch_core_session **new_session, switch_memory_pool *pool);
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
switch_io_flag flags, int stream_id);
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session)
+ switch_core_session **new_session, switch_memory_pool *pool)
{
- if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
+ if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
struct private_object *tech_pvt;
switch_channel *channel;
switch_caller_profile *caller_profile;
static switch_status channel_on_transmit(switch_core_session *session);
static switch_status channel_outgoing_channel(switch_core_session *session,
switch_caller_profile *outbound_profile,
- switch_core_session **new_session);
+ switch_core_session **new_session, switch_memory_pool *pool);
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
switch_io_flag flags, int stream_id);
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session)
+ switch_core_session **new_session, switch_memory_pool *pool)
{
- if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
+ if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
struct private_object *tech_pvt;
switch_channel *channel;
switch_caller_profile *caller_profile;
static switch_status wanpipe_on_loopback(switch_core_session *session);
static switch_status wanpipe_on_transmit(switch_core_session *session);
static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session);
+ switch_core_session **new_session, switch_memory_pool *pool);
static switch_status wanpipe_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
switch_io_flag flags, int stream_id);
static switch_status wanpipe_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
}
static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session)
+ switch_core_session **new_session, switch_memory_pool *pool)
{
if (!globals.configured_spans) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error No Spans Configured.\n");
}
- if ((*new_session = switch_core_session_request(&wanpipe_endpoint_interface, NULL))) {
+ if ((*new_session = switch_core_session_request(&wanpipe_endpoint_interface, pool))) {
struct private_object *tech_pvt;
switch_channel *channel;
static switch_status woomerachan_on_loopback(switch_core_session *session);
static switch_status woomerachan_on_transmit(switch_core_session *session);
static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session);
+ switch_core_session **new_session, switch_memory_pool *pool);
static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
switch_io_flag flags, int stream_id);
static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
- switch_core_session **new_session)
+ switch_core_session **new_session, switch_memory_pool *pool)
{
- if ((*new_session = switch_core_session_request(&woomerachan_endpoint_interface, NULL)) != 0) {
+ if ((*new_session = switch_core_session_request(&woomerachan_endpoint_interface, pool)) != 0) {
struct private_object *tech_pvt;
switch_channel *channel;
switch_core_session *session;
JSContext *cx;
JSObject *obj;
- switch_memory_pool *pool;
unsigned int flags;
};
}
caller_profile = switch_caller_profile_new(pool, dialplan, cid_name, cid_num, network_addr, ani, ani2, dest);
- if (switch_core_session_outgoing_channel(session, channel_type, caller_profile, &peer_session) == SWITCH_STATUS_SUCCESS) {
+ if (switch_core_session_outgoing_channel(session, channel_type, caller_profile, &peer_session, &pool) == SWITCH_STATUS_SUCCESS) {
jss = switch_core_session_alloc(peer_session, sizeof(*jss));
jss->session = peer_session;
jss->flags = 0;
jss->cx = cx;
jss->obj = obj;
JS_SetPrivate(cx, obj, jss);
- if (need_pool) {
- jss->pool = pool;
- }
switch_core_session_thread_launch(peer_session);
switch_set_flag(jss, S_HUP);
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Missing Args\n");
}
- if (need_pool) {
+ if (pool) {
switch_core_destroy_memory_pool(&pool);
}
return JS_FALSE;
if (cx && obj) {
if ((jss = JS_GetPrivate(cx, obj))) {
- if (jss->pool) {
- switch_core_destroy_memory_pool(&jss->pool);
- }
-
if (switch_test_flag(jss, S_HUP)) {
switch_channel *channel;
SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_session *session,
char *endpoint_name,
switch_caller_profile *caller_profile,
- switch_core_session **new_session)
+ switch_core_session **new_session,
+ switch_memory_pool **pool)
{
struct switch_io_event_hook_outgoing_channel *ptr;
switch_status status = SWITCH_STATUS_FALSE;
if (endpoint_interface->io_routines->outgoing_channel) {
if ((status =
endpoint_interface->io_routines->outgoing_channel(session, caller_profile,
- new_session)) == SWITCH_STATUS_SUCCESS) {
+ new_session, *pool)) == SWITCH_STATUS_SUCCESS) {
+ /* session has adopted this pool we cant touch it now */
+ *pool = NULL;
if (session) {
for (ptr = session->event_hooks.outgoing_channel; ptr; ptr = ptr->next) {
if ((status = ptr->outgoing_channel(session, caller_profile, *new_session)) != SWITCH_STATUS_SUCCESS) {