Browse Source

failtest: don't insist parents and children write the same thing to files.

We insist they write the same things to pipes, since we can't "undo" them,
but strictly speaking we don't care if they write different things into
files.

Note: it may indicate a bug if they do...
Rusty Russell 15 years ago
parent
commit
fb9514a55b
1 changed files with 4 additions and 3 deletions
  1. 4 3
      ccan/failtest/failtest.c

+ 4 - 3
ccan/failtest/failtest.c

@@ -663,8 +663,9 @@ ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t off,
 	call.off = off;
 	p = add_history(FAILTEST_WRITE, file, line, &call);
 
-	/* If we're a child, tell parent about write. */
-	if (control_fd != -1) {
+	/* If we're a child, we need to make sure we write the same thing
+	 * to non-files as the parent does, so tell it. */
+	if (control_fd != -1 && off == (off_t)-1) {
 		enum info_type type = WRITE;
 
 		write_all(control_fd, &type, sizeof(type));
@@ -678,7 +679,7 @@ ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t off,
 		p->error = EIO;
 	} else {
 		/* FIXME: We assume same write order in parent and child */
-		if (child_writes_num != 0) {
+		if (off == (off_t)-1 && child_writes_num != 0) {
 			if (child_writes[0].fd != fd)
 				errx(1, "Child wrote to fd %u, not %u?",
 				     child_writes[0].fd, fd);