@@ -478,9 +478,6 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
478
478
Step * * waiting ;
479
479
Step * * errorstep ;
480
480
481
- waiting = malloc (sizeof (Step * ) * testspec -> nsessions );
482
- errorstep = malloc (sizeof (Step * ) * testspec -> nsessions );
483
-
484
481
/*
485
482
* In dry run mode, just display the permutation in the same format used
486
483
* by spec files, and return.
@@ -494,6 +491,9 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
494
491
return ;
495
492
}
496
493
494
+ waiting = malloc (sizeof (Step * ) * testspec -> nsessions );
495
+ errorstep = malloc (sizeof (Step * ) * testspec -> nsessions );
496
+
497
497
printf ("\nstarting permutation:" );
498
498
for (i = 0 ; i < nsteps ; i ++ )
499
499
printf (" %s" , steps [i ]-> name );
@@ -548,14 +548,15 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
548
548
* Check whether the session that needs to perform the next step
549
549
* is still blocked on an earlier step. If so, wait for it to finish.
550
550
*
551
- * In older versions of this tool, when allowed precisely one session
552
- * to be waiting at a time. If we reached a step which 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 step that required that
553
553
* 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.)
559
560
*/
560
561
for (w = 0 ; w < nwaiting ; ++ w )
561
562
{
@@ -689,6 +690,9 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
689
690
}
690
691
PQclear (res );
691
692
}
693
+
694
+ free (waiting );
695
+ free (errorstep );
692
696
}
693
697
694
698
/*
@@ -786,12 +790,17 @@ try_complete_step(Step *step, int flags)
786
790
if (td > 60 * USECS_PER_SEC && !canceled )
787
791
{
788
792
PGcancel * cancel = PQgetCancel (conn );
789
- char buf [256 ];
790
793
791
- if (cancel != NULL && !PQcancel (cancel , buf , sizeof (buf )))
792
- fprintf (stderr , "PQcancel failed: %s\n" , buf );
793
794
if (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 );
794
802
PQfreeCancel (cancel );
803
+ }
795
804
}
796
805
797
806
/*
0 commit comments