@@ -478,9 +478,6 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
478478Step * * waiting ;
479479Step * * errorstep ;
480480
481- waiting = malloc (sizeof (Step * )* testspec -> nsessions );
482- errorstep = malloc (sizeof (Step * )* testspec -> nsessions );
483-
484481/*
485482 * In dry run mode, just display the permutation in the same format used
486483 * by spec files, and return.
@@ -494,6 +491,9 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
494491return ;
495492}
496493
494+ waiting = malloc (sizeof (Step * )* testspec -> nsessions );
495+ errorstep = malloc (sizeof (Step * )* testspec -> nsessions );
496+
497497printf ("\nstarting permutation:" );
498498for (i = 0 ;i < nsteps ;i ++ )
499499printf (" %s" ,steps [i ]-> name );
@@ -548,14 +548,15 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
548548 * Check whether the session that needs to perform the next step
549549 * is still blocked on an earlier step. If so, wait for it to finish.
550550 *
551- * In older versions of this tool,when allowed precisely one session
552- * to be waiting at a time. If we reached a stepwhich required that
551+ *( In older versions of this tool,we allowed precisely one session
552+ * to be waiting at a time. If we reached a stepthat required that
553553 * session to execute the next command, we would declare the whole
554- * permutation invalid, cancel everything, and move on to the next one.
555- * Unfortunately, that made it impossible to test the deadlock detector
556- * using this framework unless the numebr of processes involved in the
557- * deadlock was precisely two. We now assume that if we reach a step
558- * that is still blocked, we need to wait for it to unblock itself.
554+ * permutation invalid, cancel everything, and move on to the next
555+ * one. Unfortunately, that made it impossible to test the deadlock
556+ * detector using this framework, unless the number of processes
557+ * involved in the deadlock was precisely two. We now assume that if
558+ * we reach a step that is still blocked, we need to wait for it to
559+ * unblock itself.)
559560 */
560561for (w = 0 ;w < nwaiting ;++ w )
561562{
@@ -689,6 +690,9 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
689690}
690691PQclear (res );
691692}
693+
694+ free (waiting );
695+ free (errorstep );
692696}
693697
694698/*
@@ -786,12 +790,17 @@ try_complete_step(Step *step, int flags)
786790if (td > 60 * USECS_PER_SEC && !canceled )
787791{
788792PGcancel * cancel = PQgetCancel (conn );
789- char buf [256 ];
790793
791- if (cancel != NULL && !PQcancel (cancel ,buf ,sizeof (buf )))
792- fprintf (stderr ,"PQcancel failed: %s\n" ,buf );
793794if (cancel != NULL )
795+ {
796+ char buf [256 ];
797+
798+ if (PQcancel (cancel ,buf ,sizeof (buf )))
799+ canceled = true;
800+ else
801+ fprintf (stderr ,"PQcancel failed: %s\n" ,buf );
794802PQfreeCancel (cancel );
803+ }
795804}
796805
797806/*