job.c (create_batch_file): Fix last change: always increment the
authorEli Zaretskii <eliz@gnu.org>
Sat, 8 Dec 2012 10:26:36 +0000 (10:26 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 8 Dec 2012 10:26:36 +0000 (10:26 +0000)
 counter of batch files before trying to use it.

ChangeLog
job.c

index 3a70bef8ab758d8aa8cbf53be511cd789334494d..9c562be65b51065f7bbfa34b68fae419b91c876e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-08  Eli Zaretskii  <eliz@gnu.org>
+
+       * job.c (create_batch_file): Fix last change: always increment the
+       counter of batch files before trying to use it.
+
 2012-12-07  Eli Zaretskii  <eliz@gnu.org>
 
        * job.c (construct_command_argv_internal): Remove " from
diff --git a/job.c b/job.c
index 4c87ca064597d6628ca68d5779b37363ceab7224..970a2fc2f43c61a0da2495dbad0d1500f2ea1fde 100644 (file)
--- a/job.c
+++ b/job.c
@@ -273,7 +273,7 @@ create_batch_file (char const *base, int unixy, int *fd)
      available, while it really isn't.  This happens in parallel
      builds, where Make doesn't wait for one job to finish before it
      launches the next one.  */
-  static unsigned uniq = 1;
+  static unsigned uniq = 0;
   static int second_loop = 0;
   const unsigned sizemax = strlen (base) + strlen (ext) + 10;
 
@@ -283,6 +283,16 @@ create_batch_file (char const *base, int unixy, int *fd)
       path_is_dot = 1;
     }
 
+  ++uniq;
+  if (uniq >= 0x10000 && !second_loop)
+    {
+      /* If we already had 64K batch files in this
+        process, make a second loop through the numbers,
+        looking for free slots, i.e. files that were
+        deleted in the meantime.  */
+      second_loop = 1;
+      uniq = 1;
+    }
   while (path_size > 0 &&
          path_size + sizemax < sizeof temp_path &&
          !(uniq >= 0x10000 && second_loop))
@@ -309,12 +319,8 @@ create_batch_file (char const *base, int unixy, int *fd)
              ++uniq;
              if (uniq == 0x10000 && !second_loop)
                {
-                 /* If we already had 64K batch files in this
-                    process, make a second loop through the numbers,
-                    looking for free slots, i.e. files that were
-                    deleted in the meantime.  */
                  second_loop = 1;
-                 uniq = 0;
+                 uniq = 1;
                }
            }