Browse Source

Beautifying previous code

pull/262/head
Lucian Balaceanu 10 years ago
parent
commit
5732121794
4 changed files with 40 additions and 43 deletions
  1. +4
    -4
      daemon/call.c
  2. +25
    -27
      daemon/call.h
  3. +11
    -11
      daemon/graphite.c
  4. +0
    -1
      daemon/main.c

+ 4
- 4
daemon/call.c View File

@ -1980,7 +1980,7 @@ void call_destroy(struct call *c) {
continue;
char *addr = sockaddr_print_buf(&ps->endpoint.address);
char *local_addr = ps->selected_sfd ? sockaddr_print_buf(&ps->selected_sfd->socket.local.address) : "0.0.0.0";
char *local_addr = ps->selected_sfd ? sockaddr_print_buf(&ps->selected_sfd->socket.local.address) : "0.0.0.0";
if (_log_facility_cdr) {
const char* protocol = (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? "rtcp" : "rtp";
@ -1989,7 +1989,7 @@ void call_destroy(struct call *c) {
printlen = snprintf(cdrbufcur, CDRBUFREMAINDER,
"ml%i_midx%u_%s_endpoint_ip=%s, "
"ml%i_midx%u_%s_endpoint_port=%u, "
"ml%i_midx%u_%s_local_relay_ip=%s, "
"ml%i_midx%u_%s_local_relay_ip=%s, "
"ml%i_midx%u_%s_local_relay_port=%u, "
"ml%i_midx%u_%s_relayed_packets="UINT64F", "
"ml%i_midx%u_%s_relayed_bytes="UINT64F", "
@ -2017,7 +2017,7 @@ void call_destroy(struct call *c) {
printlen = snprintf(cdrbufcur, CDRBUFREMAINDER,
"ml%i_midx%u_%s_endpoint_ip=%s, "
"ml%i_midx%u_%s_endpoint_port=%u, "
"ml%i_midx%u_%s_local_relay_ip=%s, "
"ml%i_midx%u_%s_local_relay_ip=%s, "
"ml%i_midx%u_%s_local_relay_port=%u, "
"ml%i_midx%u_%s_relayed_packets="UINT64F", "
"ml%i_midx%u_%s_relayed_bytes="UINT64F", "
@ -2049,7 +2049,7 @@ void call_destroy(struct call *c) {
printlen = snprintf(cdrbufcur, CDRBUFREMAINDER,
"ml%i_midx%u_%s_endpoint_ip=%s, "
"ml%i_midx%u_%s_endpoint_port=%u, "
"ml%i_midx%u_%s_local_relay_ip=%s, "
"ml%i_midx%u_%s_local_relay_ip=%s, "
"ml%i_midx%u_%s_local_relay_port=%u, "
"ml%i_midx%u_%s_relayed_packets="UINT64F", "
"ml%i_midx%u_%s_relayed_bytes="UINT64F", "


+ 25
- 27
daemon/call.h View File

@ -245,37 +245,35 @@ struct request_time {
};
struct totalstats {
time_t started;
atomic64 total_timeout_sess;
atomic64 total_foreign_sessions;
atomic64 total_rejected_sess;
atomic64 total_silent_timeout_sess;
atomic64 total_final_timeout_sess;
atomic64 total_regular_term_sess;
atomic64 total_forced_term_sess;
atomic64 total_relayed_packets;
atomic64 total_relayed_errors;
atomic64 total_nopacket_relayed_sess;
atomic64 total_oneway_stream_sess;
u_int64_t foreign_sessions;
u_int64_t own_sessions;
u_int64_t total_sessions;
mutex_t total_average_lock; /* for these two below */
u_int64_t total_managed_sess;
time_t started;
atomic64 total_timeout_sess;
atomic64 total_foreign_sessions;
atomic64 total_rejected_sess;
atomic64 total_silent_timeout_sess;
atomic64 total_final_timeout_sess;
atomic64 total_regular_term_sess;
atomic64 total_forced_term_sess;
atomic64 total_relayed_packets;
atomic64 total_relayed_errors;
atomic64 total_nopacket_relayed_sess;
atomic64 total_oneway_stream_sess;
u_int64_t foreign_sessions;
u_int64_t own_sessions;
u_int64_t total_sessions;
mutex_t total_average_lock; /* for these two below */
u_int64_t total_managed_sess;
struct timeval total_average_call_dur;
mutex_t managed_sess_lock; /* for these below */
u_int64_t managed_sess_max; /* per graphite interval statistic */
u_int64_t managed_sess_min; /* per graphite interval statistic */
mutex_t managed_sess_lock; /* for these below */
u_int64_t managed_sess_max; /* per graphite interval statistic */
u_int64_t managed_sess_min; /* per graphite interval statistic */
mutex_t total_calls_duration_lock; /* for these two below */
mutex_t total_calls_duration_lock; /* for these two below */
struct timeval total_calls_duration_interval;
struct request_time offer, answer, delete;
struct request_time offer, answer, delete;
};
struct stream_params {
@ -461,7 +459,7 @@ struct callmaster_config {
struct event_base *redis_notify_event_base;
GQueue *redis_subscribed_keyspaces;
struct redisAsyncContext *redis_notify_async_context;
unsigned int redis_expires_secs;
unsigned int redis_expires_secs;
char *b2b_url;
unsigned char default_tos;
enum xmlrpc_format fmt;


+ 11
- 11
daemon/graphite.c View File

@ -134,11 +134,11 @@ int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data) {
mutex_lock(&cm->totalstats_interval.managed_sess_lock);
ts->managed_sess_max = cm->totalstats_interval.managed_sess_max;
ts->managed_sess_min = cm->totalstats_interval.managed_sess_min;
ts->total_sessions = g_hash_table_size(cm->callhash);
ts->foreign_sessions = atomic64_get(&cm->stats.foreign_sessions);
ts->own_sessions = ts->total_sessions - ts->foreign_sessions;
cm->totalstats_interval.managed_sess_max = ts->own_sessions;;
cm->totalstats_interval.managed_sess_min = ts->own_sessions;
ts->total_sessions = g_hash_table_size(cm->callhash);
ts->foreign_sessions = atomic64_get(&cm->stats.foreign_sessions);
ts->own_sessions = ts->total_sessions - ts->foreign_sessions;
cm->totalstats_interval.managed_sess_max = ts->own_sessions;;
cm->totalstats_interval.managed_sess_min = ts->own_sessions;
mutex_unlock(&cm->totalstats_interval.managed_sess_lock);
rwlock_unlock_r(&cm->hashlock);
@ -181,12 +181,12 @@ int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data) {
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"managed_sess_max "UINT64F" %llu\n", ts->managed_sess_max,(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"current_sessions_total "UINT64F" %llu\n", ts->total_sessions,(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"current_sessions_own "UINT64F" %llu\n", ts->own_sessions,(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"current_sessions_foreign "UINT64F" %llu\n", ts->foreign_sessions,(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"current_sessions_total "UINT64F" %llu\n", ts->total_sessions,(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"current_sessions_own "UINT64F" %llu\n", ts->own_sessions,(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"current_sessions_foreign "UINT64F" %llu\n", ts->foreign_sessions,(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"nopacket_relayed_sess "UINT64F" %llu\n", atomic64_get_na(&ts->total_nopacket_relayed_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
rc = sprintf(ptr,"oneway_stream_sess "UINT64F" %llu\n", atomic64_get_na(&ts->total_oneway_stream_sess),(unsigned long long)g_now.tv_sec); ptr += rc;


+ 0
- 1
daemon/main.c View File

@ -80,7 +80,6 @@ static int max_sessions = -1;
static int redis_db = -1;
static int redis_write_db = -1;
static int redis_num_threads;
static int no_redis_required;
static char *redis_auth;
static char *redis_write_auth;


Loading…
Cancel
Save