]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
adding code to lock term hash list before reading
authorKapil Gupta <kgupta@sangoma.com>
Mon, 27 Aug 2012 18:38:08 +0000 (14:38 -0400)
committerKapil Gupta <kgupta@sangoma.com>
Mon, 27 Aug 2012 18:38:08 +0000 (14:38 -0400)
src/mod/endpoints/mod_media_gateway/media_gateway_cli.c

index 97b3d1c79d2e181b4dce6efee518dd2cff1c91dd..24ec5989ce0fc33646dd3c6c710df8878c8e4c64 100644 (file)
@@ -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");