Commit 73bcb76b authored by Alvaro Herrera's avatar Alvaro Herrera

Make stdout unbuffered

This ensures that all stdout output is flushed immediately, to match
stderr.  This eliminates the need for fflush(stdout) calls sprinkled all
over the place.

Per Daniel Wood in message 519A79C6.90308@salesforce.com
parent 13aa6244
...@@ -70,8 +70,6 @@ exit_nicely(void) ...@@ -70,8 +70,6 @@ exit_nicely(void)
for (i = 0; i < nconns; i++) for (i = 0; i < nconns; i++)
PQfinish(conns[i]); PQfinish(conns[i]);
fflush(stderr);
fflush(stdout);
exit(1); exit(1);
} }
...@@ -101,6 +99,9 @@ main(int argc, char **argv) ...@@ -101,6 +99,9 @@ main(int argc, char **argv)
} }
} }
/* make stdout unbuffered to match stderr */
setbuf(stdout, NULL);
/* /*
* If the user supplies a non-option parameter on the command line, use it * If the user supplies a non-option parameter on the command line, use it
* as the conninfo string; otherwise default to setting dbname=postgres * as the conninfo string; otherwise default to setting dbname=postgres
...@@ -288,8 +289,6 @@ main(int argc, char **argv) ...@@ -288,8 +289,6 @@ main(int argc, char **argv)
/* Clean up and exit */ /* Clean up and exit */
for (i = 0; i < nconns; i++) for (i = 0; i < nconns; i++)
PQfinish(conns[i]); PQfinish(conns[i]);
fflush(stderr);
fflush(stdout);
return 0; return 0;
} }
...@@ -574,9 +573,7 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps) ...@@ -574,9 +573,7 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
* but it can only be unblocked by running steps from other * but it can only be unblocked by running steps from other
* sessions. * sessions.
*/ */
fflush(stdout);
fprintf(stderr, "invalid permutation detected\n"); fprintf(stderr, "invalid permutation detected\n");
fflush(stderr);
/* Cancel the waiting statement from this session. */ /* Cancel the waiting statement from this session. */
cancel = PQgetCancel(conn); cancel = PQgetCancel(conn);
...@@ -664,7 +661,6 @@ teardown: ...@@ -664,7 +661,6 @@ teardown:
testspec->sessions[i]->name, testspec->sessions[i]->name,
PQerrorMessage(conns[i + 1])); PQerrorMessage(conns[i + 1]));
/* don't exit on teardown failure */ /* don't exit on teardown failure */
fflush(stderr);
} }
PQclear(res); PQclear(res);
} }
...@@ -683,7 +679,6 @@ teardown: ...@@ -683,7 +679,6 @@ teardown:
fprintf(stderr, "teardown failed: %s", fprintf(stderr, "teardown failed: %s",
PQerrorMessage(conns[0])); PQerrorMessage(conns[0]));
/* don't exit on teardown failure */ /* don't exit on teardown failure */
fflush(stderr);
} }
PQclear(res); PQclear(res);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment