mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-03 22:26:51 +00:00
fix reply timeout: move hash and pid to session pool FS-3432
This commit is contained in:
parent
d2e9e46eb6
commit
3f6b5a5c01
@ -1108,7 +1108,7 @@ static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, e
|
|||||||
static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
|
static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
|
||||||
{
|
{
|
||||||
erlang_ref ref;
|
erlang_ref ref;
|
||||||
erlang_pid *pid;
|
erlang_pid pid;
|
||||||
char hash[100];
|
char hash[100];
|
||||||
int arity;
|
int arity;
|
||||||
const void *key;
|
const void *key;
|
||||||
@ -1123,15 +1123,7 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg,
|
|||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pid = malloc(sizeof(erlang_pid)))) {
|
if (ei_decode_pid(buf->buff, &buf->index, &pid)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error\n");
|
|
||||||
ei_x_encode_tuple_header(rbuf, 2);
|
|
||||||
ei_x_encode_atom(rbuf, "error");
|
|
||||||
ei_x_encode_atom(rbuf, "badmem");
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ei_decode_pid(buf->buff, &buf->index, pid)) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid pid in a reference/pid tuple\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid pid in a reference/pid tuple\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
@ -1149,7 +1141,9 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg,
|
|||||||
switch_mutex_lock(se->spawn_reply->mutex);
|
switch_mutex_lock(se->spawn_reply->mutex);
|
||||||
|
|
||||||
if (se->spawn_reply->state == reply_waiting) {
|
if (se->spawn_reply->state == reply_waiting) {
|
||||||
se->spawn_reply->pid = pid;
|
se->spawn_reply->pid = switch_core_alloc(se->pool, sizeof(erlang_pid));
|
||||||
|
switch_assert(se->spawn_reply->pid != NULL);
|
||||||
|
memcpy(se->spawn_reply->pid, &pid, sizeof(erlang_pid));
|
||||||
switch_thread_cond_signal(se->spawn_reply->ready_or_found);
|
switch_thread_cond_signal(se->spawn_reply->ready_or_found);
|
||||||
ei_x_encode_atom(rbuf, "ok");
|
ei_x_encode_atom(rbuf, "ok");
|
||||||
switch_thread_rwlock_unlock(listener->session_rwlock);
|
switch_thread_rwlock_unlock(listener->session_rwlock);
|
||||||
@ -1167,8 +1161,6 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg,
|
|||||||
ei_x_encode_atom(rbuf, "error");
|
ei_x_encode_atom(rbuf, "error");
|
||||||
ei_x_encode_atom(rbuf, "notfound");
|
ei_x_encode_atom(rbuf, "notfound");
|
||||||
|
|
||||||
switch_safe_free(pid); /* don't need it */
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,7 +1377,7 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul
|
|||||||
switch_thread_cond_create(&p->ready_or_found, session_element->pool);
|
switch_thread_cond_create(&p->ready_or_found, session_element->pool);
|
||||||
switch_mutex_init(&p->mutex, SWITCH_MUTEX_UNNESTED, session_element->pool);
|
switch_mutex_init(&p->mutex, SWITCH_MUTEX_UNNESTED, session_element->pool);
|
||||||
p->state = reply_waiting;
|
p->state = reply_waiting;
|
||||||
p->hash = hash;
|
p->hash = switch_core_strdup(session_element->pool, hash);
|
||||||
p->pid = NULL;
|
p->pid = NULL;
|
||||||
|
|
||||||
session_element->spawn_reply = p;
|
session_element->spawn_reply = p;
|
||||||
@ -1437,8 +1437,6 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul
|
|||||||
|
|
||||||
ei_link(listener, ei_self(listener->ec), &session_element->process.pid);
|
ei_link(listener, ei_self(listener->ec), &session_element->process.pid);
|
||||||
|
|
||||||
switch_safe_free(p->pid);
|
|
||||||
|
|
||||||
return session_element;
|
return session_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user