]> git.ipfire.org Git - thirdparty/make.git/commitdiff
jobserver: Ensure the named pipe is deleted on error
authorPaul Smith <psmith@gnu.org>
Sun, 8 Dec 2024 21:27:06 +0000 (16:27 -0500)
committerPaul Smith <psmith@gnu.org>
Mon, 9 Dec 2024 04:30:37 +0000 (23:30 -0500)
Make sure the jobserver named pipe is deleted even if the
jobserver_setup() function calls fatal() and exits early.

* src/main.c (clean_jobserver): Always reset_jobserver().
* src/posixos.c (jobserver_setup): Set job_root up front.
* tests/test_driver.pl: Print out the logfile pathname on error.
For tests with regex matches this might be the only file available.
Don't print the base filename unless one is created.

src/main.c
src/posixos.c
tests/test_driver.pl

index 78084d09575df8874949c2c354c7b9fb586ff15d..6a129768093c24b42000a500ade9dcde20e8ce1e 100644 (file)
@@ -3826,9 +3826,9 @@ clean_jobserver (int status)
         ONN (error, NILF,
              "INTERNAL: exiting with %u jobserver tokens available; should be %u!",
              tokens, master_job_slots);
-
-      reset_jobserver ();
     }
+
+  reset_jobserver ();
 }
 \f
 /* Exit with STATUS, cleaning up as necessary.  */
index 6b0b716e79b638272d8ba14665757dd45a0489a9..163ca6ed45e1d4afe862d10f999e9214513048b8 100644 (file)
@@ -147,6 +147,9 @@ jobserver_setup (int slots, const char *style)
 {
   int r;
 
+  /* This function sets up the root jobserver.  */
+  job_root = 1;
+
 #if JOBSERVER_USE_FIFO
   if (!style || strcmp (style, "fifo") == 0)
     {
@@ -218,8 +221,6 @@ jobserver_setup (int slots, const char *style)
   /* When using pselect() we want the read to be non-blocking.  */
   set_blocking (job_fds[0], 0);
 
-  job_root = 1;
-
   return 1;
 }
 
index 9df598c3b60ca6f4351498ebef749cf305ccdcbd..810442ffa2748ce4364ba3a0c09b14383fa52e87 100644 (file)
@@ -399,8 +399,9 @@ sub toplevel
         ++$i;
         print "  Failure $i:\n";
         print "    run:  $e->{'run'}\n" if exists($e->{'run'});
-        print "    base: $e->{'base'}\n";
+        print "    base: $e->{'base'}\n" if exists($e->{'base'});
         print "    diff: $e->{'diff'}\n" if exists($e->{'diff'});
+        print "    log:  $e->{'log'}\n" if exists($e->{'log'});
     }
     return 0;
   }
@@ -1032,11 +1033,12 @@ sub compare_output
   my $run = get_runfile();
   my $diff = get_difffile();
 
-  my %e = ('base' => File::Spec->catdir($testpath, $base));
+  my %e = ('log' => File::Spec->catdir($testpath, $logfile));
 
   if (! $matched) {
     &create_file($base, $answer);
     &create_file($run, $command_string);
+    $e{'base'} = File::Spec->catdir($testpath, $base);
     $e{'run'} = File::Spec->catdir($testpath, $run);
   }