mirror of
https://github.com/kdlucas/byte-unixbench.git
synced 2024-12-11 23:30:07 +08:00
Fix Result Report Race Condition in Pipe-based Context Switching Test (#42)
* Fix Result Report Race Condition in Pipe-based Context Switching Test Ensure all report() calls yield correct information. * Simplify code in Pipe-based Context Switching Test Remove un-needed iter1 variable
This commit is contained in:
parent
34ecf4ec6a
commit
35efe5e575
@ -94,9 +94,6 @@ char *argv[];
|
||||
}
|
||||
}
|
||||
else { /* child process */
|
||||
unsigned long iter1;
|
||||
|
||||
iter1 = 0;
|
||||
/* slave, read p1 & write p2 */
|
||||
close(p1[1]); close(p2[0]);
|
||||
while (1) {
|
||||
@ -109,12 +106,12 @@ char *argv[];
|
||||
perror("slave read failed");
|
||||
exit(1);
|
||||
}
|
||||
if (check != iter1) {
|
||||
if (check != iter) {
|
||||
fprintf(stderr, "Slave sync error: expect %lu, got %lu\n",
|
||||
iter, check);
|
||||
exit(2);
|
||||
}
|
||||
if ((ret = write(p2[1], (char *)&iter1, sizeof(iter1))) != sizeof(check)) {
|
||||
if ((ret = write(p2[1], (char *)&iter, sizeof(iter))) != sizeof(check)) {
|
||||
if ((ret == -1) && (errno == EPIPE)) {
|
||||
alarm(0);
|
||||
report(); /* does not return */
|
||||
@ -123,7 +120,7 @@ char *argv[];
|
||||
perror("slave write failed");
|
||||
exit(1);
|
||||
}
|
||||
iter1++;
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user