code cleanup

pull/291/head
lordrasmus 2 years ago
parent 88c8d0aa0c
commit b3b6604f55

@ -28,11 +28,11 @@ typedef struct host_entry {
int64_t total_time_i; /* sum of response times */ int64_t total_time_i; /* sum of response times */
int64_t *resp_times; /* individual response times */ int64_t *resp_times; /* individual response times */
int top_view_print_pos; int top_view_print_pos; /* line where the host is printed */
int64_t top_view_last_timeouts; int64_t top_view_last_timeouts; /* timeout Counter */
int64_t top_view_last_timeouts_count; int64_t top_view_last_timeouts_count; /* how many timeout occurred */
int64_t top_view_last_timeouts_seq; int64_t top_view_last_timeouts_seq; /* how many packets where lost till the next answer arrived */
char last_timeout_time[100]; char top_view_last_timeout_time[100]; /* buffer to print how long the last timeout was ( packets * period ) */
/* to avoid allocating two struct events each time that we send a ping, we /* to avoid allocating two struct events each time that we send a ping, we
* preallocate here two struct events for each ping that we might send for * preallocate here two struct events for each ping that we might send for

@ -1322,7 +1322,7 @@ void main_loop()
} }
printf("\n"); printf("\n");
}else{ }else{
print_top_view( h, 1 ); top_view_print( h, 1 );
} }
} }
@ -2455,7 +2455,7 @@ int wait_for_reply(int64_t wait_time)
printf("\n"); printf("\n");
}else{ }else{
print_top_view( h, 0 ); top_view_print( h, 0 );
} }
} }

@ -96,13 +96,13 @@ static void print_top_view_init( void ){
void print_top_view( HOST_ENTRY *h, int timeout ) { void top_view_print( HOST_ENTRY *h, int timeout ) {
print_top_view_init(); print_top_view_init();
if ( h->top_view_print_pos == 0 ){ if ( h->top_view_print_pos == 0 ){
h->top_view_print_pos = next_view_pos++; h->top_view_print_pos = next_view_pos++;
sprintf(h->last_timeout_time, "0 ms" ); sprintf(h->top_view_last_timeout_time, "0 ms" );
} }
@ -113,7 +113,7 @@ void print_top_view( HOST_ENTRY *h, int timeout ) {
h->top_view_last_timeouts++; h->top_view_last_timeouts++;
h->top_view_last_timeouts_seq = h->top_view_last_timeouts; h->top_view_last_timeouts_seq = h->top_view_last_timeouts;
sprintf(h->last_timeout_time, "%"PRIi64" ms ", h->top_view_last_timeouts * ( perhost_interval / 1000 / 1000 ) ); sprintf(h->top_view_last_timeout_time, "%"PRIi64" ms ", h->top_view_last_timeouts * ( perhost_interval / 1000 / 1000 ) );
}else{ }else{
@ -134,7 +134,7 @@ void print_top_view( HOST_ENTRY *h, int timeout ) {
pos_printf( 5 + h->top_view_print_pos, TIMEOUT_TOTAL_POS , "%"PRIi64, h->top_view_last_timeouts_count); pos_printf( 5 + h->top_view_print_pos, TIMEOUT_TOTAL_POS , "%"PRIi64, h->top_view_last_timeouts_count);
pos_printf( 5 + h->top_view_print_pos, TIMEOUT_SEQ_POS , "%"PRIi64, h->top_view_last_timeouts_seq); pos_printf( 5 + h->top_view_print_pos, TIMEOUT_SEQ_POS , "%"PRIi64, h->top_view_last_timeouts_seq);
pos_printf( 5 + h->top_view_print_pos, TIMEOUT_TIME_POS , "%s", h->last_timeout_time); pos_printf( 5 + h->top_view_print_pos, TIMEOUT_TIME_POS , "%s", h->top_view_last_timeout_time);

@ -2,7 +2,7 @@
#include "data_types.h" #include "data_types.h"
void print_top_view( HOST_ENTRY *h, int timeout ); void top_view_print( HOST_ENTRY *h, int timeout );
void top_view_end( void ); void top_view_end( void );

Loading…
Cancel
Save