Skip to content

Commit c8ed964

Browse files
Merge pull request #85 from kevinGC/divbyzero
fix divide by zero error
2 parents 151cac7 + f263d2c commit c8ed964

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

thread.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -662,16 +662,17 @@ int run_main_thread(struct options *opts, struct callbacks *cb,
662662
control_plane_destroy(cp);
663663

664664
if (opts->rx_zerocopy) {
665-
uint64_t total_rx_zc_bytes = 0;
666-
uint64_t total_rx_bytes = 0;
667-
uint64_t percent_mmaped;
665+
uint64_t total_zc_bytes = 0;
666+
uint64_t total_bytes = 0;
667+
uint64_t percent_mmaped = 0;
668668

669669
for (int i = 0; i < opts->num_threads; i++) {
670-
total_rx_zc_bytes += ts[i].io_stats.rx_zc_bytes;
671-
total_rx_bytes += ts[i].io_stats.rx_bytes;
670+
total_zc_bytes += ts[i].io_stats.rx_zc_bytes;
671+
total_bytes += ts[i].io_stats.rx_bytes;
672672
}
673-
percent_mmaped = 100 * total_rx_zc_bytes / total_rx_bytes;
674-
PRINT(cb, "bytes_mmaped", "%lu", total_rx_zc_bytes);
673+
if (total_zc_bytes > 0)
674+
percent_mmaped = 100 * total_zc_bytes / total_bytes;
675+
PRINT(cb, "bytes_mmaped", "%lu", total_zc_bytes);
675676
PRINT(cb, "percent_mmaped", "%lu", percent_mmaped);
676677
if (percent_mmaped < 10) {
677678
LOG_WARN(cb, "Little traffic is being handled by "

0 commit comments

Comments
 (0)