/* In dry run only output permutations to be run by the tester. */
static int dry_run = false;
-static void exit_nicely(void) pg_attribute_noreturn();
static void run_testspec(TestSpec *testspec);
static void run_all_permutations(TestSpec *testspec);
static void run_all_permutations_recurse(TestSpec *testspec, int nsteps,
static void isotesterNoticeProcessor(void *arg, const char *message);
static void blackholeNoticeProcessor(void *arg, const char *message);
-/* close all connections and exit */
static void
-exit_nicely(void)
+disconnect_atexit(void)
{
int i;
for (i = 0; i < nconns; i++)
- PQfinish(conns[i]);
- exit(1);
+ if (conns[i])
+ PQfinish(conns[i]);
}
int
{
fprintf(stderr, "duplicate step name: %s\n",
testspec->allsteps[i]->name);
- exit_nicely();
+ exit(1);
}
}
*/
nconns = 1 + testspec->nsessions;
conns = calloc(nconns, sizeof(PGconn *));
+ atexit(disconnect_atexit);
backend_pids = calloc(nconns, sizeof(*backend_pids));
for (i = 0; i < nconns; i++)
{
{
fprintf(stderr, "Connection %d to database failed: %s",
i, PQerrorMessage(conns[i]));
- exit_nicely();
+ exit(1);
}
/*
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "message level setup failed: %s", PQerrorMessage(conns[i]));
- exit_nicely();
+ exit(1);
}
PQclear(res);
{
fprintf(stderr, "backend pid query returned %d rows and %d columns, expected 1 row and 1 column",
PQntuples(res), PQnfields(res));
- exit_nicely();
+ exit(1);
}
}
else
{
fprintf(stderr, "backend pid query failed: %s",
PQerrorMessage(conns[i]));
- exit_nicely();
+ exit(1);
}
PQclear(res);
}
{
fprintf(stderr, "prepare of lock wait query failed: %s",
PQerrorMessage(conns[0]));
- exit_nicely();
+ exit(1);
}
PQclear(res);
termPQExpBuffer(&wait_query);
*/
run_testspec(testspec);
- /* Clean up and exit */
- for (i = 0; i < nconns; i++)
- PQfinish(conns[i]);
return 0;
}
{
fprintf(stderr, "undefined step \"%s\" specified in permutation\n",
p->stepnames[j]);
- exit_nicely();
+ exit(1);
}
steps[j] = *this;
}
else if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "setup failed: %s", PQerrorMessage(conns[0]));
- exit_nicely();
+ exit(1);
}
PQclear(res);
}
fprintf(stderr, "setup of session %s failed: %s",
testspec->sessions[i]->name,
PQerrorMessage(conns[i + 1]));
- exit_nicely();
+ exit(1);
}
PQclear(res);
}
{
fprintf(stdout, "failed to send query for step %s: %s\n",
step->name, PQerrorMessage(conn));
- exit_nicely();
+ exit(1);
}
/* Try to complete this step without blocking. */
if (sock < 0)
{
fprintf(stderr, "invalid socket: %s", PQerrorMessage(conn));
- exit_nicely();
+ exit(1);
}
gettimeofday(&start_time, NULL);
if (errno == EINTR)
continue;
fprintf(stderr, "select failed: %s\n", strerror(errno));
- exit_nicely();
+ exit(1);
}
else if (ret == 0) /* select() timeout: check for lock wait */
{
{
fprintf(stderr, "lock wait query failed: %s",
PQerrorMessage(conns[0]));
- exit_nicely();
+ exit(1);
}
waiting = ((PQgetvalue(res, 0, 0))[0] == 't');
PQclear(res);
{
fprintf(stderr, "step %s timed out after 200 seconds\n",
step->name);
- exit_nicely();
+ exit(1);
}
}
else if (!PQconsumeInput(conn)) /* select(): data available */
{
fprintf(stderr, "PQconsumeInput failed: %s\n",
PQerrorMessage(conn));
- exit_nicely();
+ exit(1);
}
}