From c670489495c6911b52e80cbd6cd51b4ee451ca29 Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Mon, 27 Aug 2012 14:38:08 -0400 Subject: [PATCH] adding code to lock term hash list before reading --- .../endpoints/mod_media_gateway/media_gateway_cli.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c index 97b3d1c79d..24ec5989ce 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c @@ -740,10 +740,13 @@ switch_status_t handle_all_term_status_cli_cmd(switch_stream_handle_t *stream, m stream->write_function(stream, " Termination Name"); stream->write_function(stream, "\t Termination State"); + stream->write_function(stream, "\t Call State"); stream->write_function(stream, "\t Termination Type"); stream->write_function(stream, "\t Span-Id "); stream->write_function(stream, "\t Channel-Id "); + switch_thread_rwlock_rdlock(mg_profile->terminations_rwlock); + for (hi = switch_hash_first(NULL, mg_profile->terminations); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, &var, NULL, &val); term = (mg_termination_t *) val; @@ -758,6 +761,8 @@ switch_status_t handle_all_term_status_cli_cmd(switch_stream_handle_t *stream, m stream->write_function(stream, "\t\t\t %s", (switch_test_flag(term, MG_IN_SERVICE))?"IN-SERVICE":"OUT-OF-SERVICE"); } + + stream->write_function(stream, "\t\t%s",(NULL != term->uuid)?"IN-CALL ":"IDLE "); stream->write_function(stream, "\t\t %s",(MG_TERM_RTP == term->type)?"MG_TERM_RTP":"MG_TERM_TDM"); if(MG_TERM_TDM == term->type){ @@ -771,6 +776,8 @@ switch_status_t handle_all_term_status_cli_cmd(switch_stream_handle_t *stream, m stream->write_function(stream, "\n"); } + switch_thread_rwlock_unlock(mg_profile->terminations_rwlock); + return SWITCH_STATUS_SUCCESS; } /******************************************************************************/ @@ -849,6 +856,9 @@ switch_status_t handle_show_activecalls_cli_cmd(switch_stream_handle_t *stream, } stream->write_function(stream, "\n ------- Active Calls Terminations ------- \n"); + + switch_thread_rwlock_rdlock(mg_profile->terminations_rwlock); + for (hi = switch_hash_first(NULL, mg_profile->terminations); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, &var, NULL, &val); term = (mg_termination_t *) val; @@ -870,6 +880,8 @@ switch_status_t handle_show_activecalls_cli_cmd(switch_stream_handle_t *stream, stream->write_function(stream, "\n ********************************* \n"); } + switch_thread_rwlock_unlock(mg_profile->terminations_rwlock); + if(!found) stream->write_function(stream, "\n ------- NO Active Calls FOUND ------- \n");