From 3ba5c72977f6f3fd26c935717842f35dd48f5ad5 Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Thu, 10 May 2012 10:19:45 +0200 Subject: [PATCH] release mutex after iterating over channel vars --- .../event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c b/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c index f2ecd35a4a..4c8aded61c 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c @@ -124,11 +124,16 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) /* Channel variables */ bson_append_start_object(&cdr, "variables"); - for (hi = switch_channel_variable_first(channel); hi; hi = hi->next) { - if (!zstr(hi->name) && !zstr(hi->value)) { - bson_append_string(&cdr, hi->name, hi->value); + + if ((hi = switch_channel_variable_first(channel))) { + for (; hi; hi = hi->next) { + if (!zstr(hi->name) && !zstr(hi->value)) { + bson_append_string(&cdr, hi->name, hi->value); + } } + switch_channel_variable_last(channel); } + bson_append_finish_object(&cdr); /* variables */