From 0a8c1a04c48f409e827b80ccb8ea562bdca8a9fb Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Mon, 8 Nov 2010 20:57:21 +0100 Subject: [PATCH 1/2] ftmod_libpri: Minor cleanups. Signed-off-by: Stefan Knoblich --- libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c index 317c9a5428..de4fa2b232 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c @@ -35,8 +35,8 @@ #include "private/ftdm_core.h" #include "lpwrap_pri.h" -#ifndef HAVE_GETTIMEOFDAY +#ifndef HAVE_GETTIMEOFDAY #ifdef WIN32 #include @@ -239,8 +239,8 @@ int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t * int lpwrap_one_loop(struct lpwrap_pri *spri) { fd_set rfds, efds; - struct timeval now = {0,0}, *next; - pri_event *event; + struct timeval now = {0,0}, *next = NULL; + pri_event *event = NULL; event_handler handler; int sel; From 49b6237ed2dc0b536ffd8114e0c5f233e133e3ff Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 8 Nov 2010 15:04:51 -0600 Subject: [PATCH 2/2] avoid hypothetical problem with flushing queue with delayed events --- src/switch_core_session.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 1589bebb67..b3bb638c76 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -790,10 +790,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_ SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(switch_core_session_t *session) { + switch_status_t status = SWITCH_STATUS_FALSE; + void *pop; switch_core_session_message_t *message; - while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) { - switch_core_session_free_message(&message); + switch_assert(session != NULL); + + if (session->message_queue) { + while ((status = (switch_status_t) switch_queue_trypop(session->message_queue, &pop)) == SWITCH_STATUS_SUCCESS) { + message = (switch_core_session_message_t *) pop; + switch_core_session_free_message(&message); + } } return SWITCH_STATUS_SUCCESS;