Skip to content

Commit

Permalink
Merge pull request grpc#4626 from ctiller/wtfwin
Browse files Browse the repository at this point in the history
Add an early out to gpr_cpu_test
  • Loading branch information
a-veitch committed Jan 7, 2016
2 parents 9ac9c12 + 0eaf296 commit 9b028b2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/core/support/cpu_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ struct cpu_test {
int is_done;
gpr_cv done_cv;
int *used; /* is this core used? */
int r; /* random number */
unsigned r; /* random number */
};

static void worker_thread(void *arg) {
struct cpu_test *ct = (struct cpu_test *)arg;
uint32_t cpu;
int r = 12345678;
int i, j;
unsigned r = 12345678;
unsigned i, j;
for (i = 0; i < 1000 / GRPC_TEST_SLOWDOWN_FACTOR; i++) {
/* run for a bit - just calculate something random. */
for (j = 0; j < 1000000 / GRPC_TEST_SLOWDOWN_FACTOR; j++) {
Expand All @@ -90,7 +90,13 @@ static void worker_thread(void *arg) {
GPR_ASSERT(cpu < ct->ncores);
gpr_mu_lock(&ct->mu);
ct->used[cpu] = 1;
for (j = 0; j < ct->ncores; j++) {
if (!ct->used[j]) break;
}
gpr_mu_unlock(&ct->mu);
if (j == ct->ncores) {
break; /* all cpus have been used - no further use in running this test */
}
}
gpr_mu_lock(&ct->mu);
ct->r = r; /* make it look like we care about r's value... */
Expand Down

0 comments on commit 9b028b2

Please sign in to comment.