@@ -459,14 +459,19 @@ sub match_log {
459459return ;
460460}
461461
462- $timeout = 0unless (defined $timeout );
462+ $timeout = 1unless (defined $timeout );
463+
464+ if ($timeout == 1)
465+ {
466+ $timeout = 0.5;
467+ }
463468
464469# Audit logs are taking too long to be written on the disk. One of the
465470# consequence of that is to have tests that demands to read from audit
466471# log failing. Increase the timeout here, make it wait a little bit
467472# more for the logs before gave up.
468473if ($name eq " audit" ) {
469- $timeout =20 ;
474+ $timeout =8 ;
470475}
471476
472477my $i = 0;
@@ -490,6 +495,7 @@ sub match_log {
490495# dbg("Match \"$re\" in $name \"$$rbuf\" ($n)");
491496if ($$rbuf =~m /$re / m ) {
492497$rc =$& ;
498+ # print "bonga\n";
493499last ;
494500 }
495501# TODO: Use select()/poll()
@@ -503,6 +509,7 @@ sub match_log {
503509print STDERR " ."
504510 }
505511 }
512+ system (" sync" );
506513 }while (gettimeofday -$t0 <$timeout );
507514 }
508515print STDERR " \n " if ($graphed );
@@ -619,14 +626,16 @@ sub nginx_stop {
619626$rc = -1;
620627}
621628
622- sleep 0.5;
623- if (-e $PID_FILE ) {
624- vrb(" Nginx pid file still exists, sleeping for more 20 seconds." );
625- sleep 20;
629+ unless (defined match_log(" error" ,qr / signal [0-9]+\( SIGCHLD\) received/ , 60," exited with code 0" )) {
630+ vrb(join (" " ,map { quote_shell($_ ) }@p ));
631+ msg(" nginx server failed to shutdown." );
632+ sleep 0.5;
633+ return -1;
634+ }
626635
627- if (-e $PID_FILE ) {
628- msg(" Nginx stop failed: $PID_FILE still exists " );
629- }
636+ if (-e $PID_FILE ) {
637+ msg(" nginx server failed to shutdown. " );
638+ return -1;
630639}
631640
632641return $rc ;
@@ -767,14 +776,13 @@ sub nginx_start {
767776$rc = -1;
768777}
769778
770- # Look for startup msg
771- # unless (defined match_log("error", qr/start worker process/, 60, "Waiting on nginx to start: ")) {
772- # vrb(join(" ", map { quote_shell($_) } @p));
773- # vrb(match_log("error", qr/(^.*ModSecurity: .*)/sm, 10));
774- # msg("Nginx server failed to start.");
775- # nginx_stop();
776- # return -1;
777- # }
779+ # Look for startup msworker cycleg
780+ unless (defined match_log(" error" ,qr / setproctitle: "nginx: worker process"/ , 60," worker cycle" )) {
781+ vrb(join (" " ,map { quote_shell($_ ) }@p ));
782+ msg(" Nginx server failed to start." );
783+ nginx_stop();
784+ return -1;
785+ }
778786
779787return $rc ;
780788}