Skip to content

Commit

Permalink
only calculate CRC once
Browse files Browse the repository at this point in the history
Signed-off-by: William Henderson <william.henderson@nutanix.com>
  • Loading branch information
w-henderson committed Jul 24, 2023
1 parent 7b20ead commit 6586ece
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions samples/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,13 +827,11 @@ fake_guest(void *arg)
int ret;
char buf[fake_guest_data->bar1_size];
FILE *fp = fopen("/dev/urandom", "r");
uint32_t crc = 0;

if (fp == NULL) {
err(EXIT_FAILURE, "failed to open /dev/urandom");
}


do {
ret = fread(buf, fake_guest_data->bar1_size, 1, fp);
if (ret != 1) {
Expand All @@ -844,11 +842,9 @@ fake_guest(void *arg)
if (ret != 0) {
err(EXIT_FAILURE, "fake guest failed to write garbage to BAR1");
}
crc = rte_hash_crc(buf, fake_guest_data->bar1_size, 0);
__sync_synchronize();
} while (!fake_guest_data->done);

*fake_guest_data->crcp = crc;
*fake_guest_data->crcp = rte_hash_crc(buf, fake_guest_data->bar1_size, 0);

return NULL;
}
Expand Down

0 comments on commit 6586ece

Please sign in to comment.