提交 ac0549e2 authored 作者: Christopher Rienzo's avatar Christopher Rienzo

Merge pull request #1047 in FS/freeswitch from ~CRIENZO/freeswitch:fs-9713 to master

* commit 'ff6ab87f':
  FS-9713 [mod_hiredis] handle spurious wakeup while waiting for connection
......@@ -73,9 +73,12 @@ static void hiredis_context_release(hiredis_context_t *context, switch_core_sess
static hiredis_context_t *hiredis_connection_get_context(hiredis_connection_t *conn, switch_core_session_t *session)
{
void *val = NULL;
switch_time_t now = switch_time_now();
switch_time_t timeout = now + conn->timeout_us;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "hiredis: waiting for [%s, %d]\n", conn->host, conn->port);
if ( switch_queue_pop_timeout(conn->context_pool, &val, conn->timeout_us ) == SWITCH_STATUS_SUCCESS ) {
while (now < timeout) {
if ( switch_queue_pop_timeout(conn->context_pool, &val, timeout - now) == SWITCH_STATUS_SUCCESS ) {
hiredis_context_t *context = (hiredis_context_t *)val;
if ( !context->context ) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "hiredis: attempting[%s, %d]\n", conn->host, conn->port);
......@@ -102,9 +105,10 @@ static hiredis_context_t *hiredis_connection_get_context(hiredis_connection_t *c
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "hiredis: recycled from pool[%s, %d]\n", conn->host, conn->port);
return context;
}
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "hiredis: timed out waiting for [%s, %d]\n", conn->host, conn->port);
}
now = switch_time_now();
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "hiredis: timed out waiting for [%s, %d]\n", conn->host, conn->port);
return NULL;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论