mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-31 10:46:27 +00:00
Ensure events received while a pid session is being created aren't discarded but are queued instead
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11500 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c86ccc9394
commit
ce11c29553
@ -487,6 +487,10 @@ static switch_status_t check_attached_sessions(listener_t *listener)
|
|||||||
sp = listener->session_list;
|
sp = listener->session_list;
|
||||||
last = NULL;
|
last = NULL;
|
||||||
while(sp) {
|
while(sp) {
|
||||||
|
if (switch_test_flag(sp, LFLAG_WAITING_FOR_PID)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!switch_test_flag(sp, LFLAG_OUTBOUND_INIT)) {
|
if (!switch_test_flag(sp, LFLAG_OUTBOUND_INIT)) {
|
||||||
status = notify_new_session(listener, sp->session, sp->process);
|
status = notify_new_session(listener, sp->session, sp->process);
|
||||||
if (status != SWITCH_STATUS_SUCCESS)
|
if (status != SWITCH_STATUS_SUCCESS)
|
||||||
@ -494,7 +498,7 @@ static switch_status_t check_attached_sessions(listener_t *listener)
|
|||||||
switch_set_flag(sp, LFLAG_OUTBOUND_INIT);
|
switch_set_flag(sp, LFLAG_OUTBOUND_INIT);
|
||||||
}
|
}
|
||||||
/* check event queue for this session */
|
/* check event queue for this session */
|
||||||
if (switch_queue_trypop(sp->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
if (switch_queue_trypop(sp->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_t *pevent = (switch_event_t *) pop;
|
switch_event_t *pevent = (switch_event_t *) pop;
|
||||||
|
|
||||||
/* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
|
/* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
|
||||||
@ -997,6 +1001,12 @@ session_elem_t* attach_call_to_spawned_process(listener_t* listener, char *modul
|
|||||||
erlang_pid *pid;
|
erlang_pid *pid;
|
||||||
erlang_ref ref;
|
erlang_ref ref;
|
||||||
|
|
||||||
|
switch_set_flag(session_element, LFLAG_WAITING_FOR_PID);
|
||||||
|
switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session));
|
||||||
|
switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||||
|
/* attach the session to the listener */
|
||||||
|
add_session_elem_to_listener(listener,session_element);
|
||||||
|
|
||||||
if (!strcmp(function, "!")) {
|
if (!strcmp(function, "!")) {
|
||||||
/* send a message to request a pid */
|
/* send a message to request a pid */
|
||||||
ei_x_buff rbuf;
|
ei_x_buff rbuf;
|
||||||
@ -1022,6 +1032,7 @@ session_elem_t* attach_call_to_spawned_process(listener_t* listener, char *modul
|
|||||||
if (i > 50) { /* half a second timeout */
|
if (i > 50) { /* half a second timeout */
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "timed out!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "timed out!\n");
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
|
remove_session_elem_from_listener(listener,session_element);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@ -1030,16 +1041,13 @@ session_elem_t* attach_call_to_spawned_process(listener_t* listener, char *modul
|
|||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got pid!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got pid!\n");
|
||||||
|
|
||||||
ei_link(listener, ei_self(listener->ec), pid);
|
|
||||||
|
|
||||||
session_element->process.type = ERLANG_PID;
|
session_element->process.type = ERLANG_PID;
|
||||||
memcpy(&session_element->process.pid, pid, sizeof(erlang_pid));
|
memcpy(&session_element->process.pid, pid, sizeof(erlang_pid));
|
||||||
switch_set_flag(session_element, LFLAG_SESSION_ALIVE);
|
switch_set_flag(session_element, LFLAG_SESSION_ALIVE);
|
||||||
switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT);
|
switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT);
|
||||||
switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session));
|
switch_clear_flag(session_element, LFLAG_WAITING_FOR_PID);
|
||||||
switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
|
||||||
/* attach the session to the listener */
|
ei_link(listener, ei_self(listener->ec), pid);
|
||||||
add_session_elem_to_listener(listener,session_element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return session_element;
|
return session_element;
|
||||||
|
@ -35,8 +35,9 @@
|
|||||||
#define EI_DEBUG
|
#define EI_DEBUG
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LFLAG_OUTBOUND_INIT = (1 << 0), /* Erlang peer has been notified of this session */
|
LFLAG_WAITING_FOR_PID = (1 << 0), /* waiting for a node to return a pid */
|
||||||
LFLAG_SESSION_ALIVE
|
LFLAG_OUTBOUND_INIT = (1 << 1), /* Erlang peer has been notified of this session */
|
||||||
|
LFLAG_SESSION_ALIVE = (1 << 2),
|
||||||
} session_flag_t;
|
} session_flag_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user