Skip to content

Commit

Permalink
tool - ndp: [FIX] do not clear main counters in multithread stats
Browse files Browse the repository at this point in the history
This allows to correctly check packet limits.
  • Loading branch information
martinspinler committed Aug 30, 2024
1 parent 2f8dd4e commit d95cc50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 6 additions & 4 deletions tools/ndptool/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ typedef enum fastwrite_mode {
struct stats_info {
unsigned long long packet_cnt;
unsigned long long bytes_cnt;

unsigned long long last_packet_cnt;
unsigned long long last_bytes_cnt;
unsigned long long last_update;
unsigned long long progress_counter;
unsigned long long sampling;
char progress_letter;
enum progress_type progress_type;

unsigned long long thread_packet_cnt;
unsigned long long thread_bytes_cnt;
unsigned long long thread_total_bytes_cnt;
void *priv;

char progress_letter;
enum progress_type progress_type;
bool incremental;

struct timeval startTime;
Expand Down
12 changes: 7 additions & 5 deletions tools/ndptool/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,17 @@ void update_stats_thread(struct ndp_packet *packets, int count, struct stats_inf
{
update_print_progress(packets, count, si);

if (si->packet_cnt > 100000 || count == 0) {
si->last_update += count;
if (si->last_update > 100000 || count == 0) {
/* Update global stats */
pthread_spin_lock(&((struct thread_data *)si->priv)->lock);
si->thread_packet_cnt += si->packet_cnt;
si->thread_bytes_cnt += si->bytes_cnt;
si->thread_packet_cnt += (si->packet_cnt - si->last_packet_cnt);
si->thread_bytes_cnt += (si->bytes_cnt - si->last_bytes_cnt);
pthread_spin_unlock(&((struct thread_data *)si->priv)->lock);

si->packet_cnt = 0;
si->bytes_cnt = 0;
si->last_packet_cnt = si->packet_cnt;
si->last_bytes_cnt = si->bytes_cnt;
si->last_update = 0;
}
}

Expand Down

0 comments on commit d95cc50

Please sign in to comment.