pack-objects: set number of threads before checking and warning
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Oct 2014 19:46:14 +0000 (12:46 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Oct 2014 19:53:46 +0000 (12:53 -0700)
Under NO_PTHREADS build, we warn when delta_search_threads is not
set to 1, because that is the only sensible value on a single
threaded build.

However, the auto detection that kicks in when that variable is set
to 0 (e.g. there is no configuration variable or command line option,
or an explicit --threads=0 is given from the command line to override
the pack.threads configuration to force auto-detection) was not done
before the condition to issue this warning was tested.

Move the auto-detection code and place it at an appropriate spot.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
thread-utils.h
index d39193453a6bf868f8b62dac18201b0b4b7bccbd..a71523706a1837c17cb0a54ceb50fc2e9e79311b 100644 (file)
@@ -1972,8 +1972,6 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
 
        init_threaded_search();
 
-       if (!delta_search_threads)      /* --threads=0 means autodetect */
-               delta_search_threads = online_cpus();
        if (delta_search_threads <= 1) {
                find_deltas(list, &list_size, window, depth, processed);
                cleanup_threaded_search();
@@ -2685,6 +2683,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                pack_compression_level = Z_DEFAULT_COMPRESSION;
        else if (pack_compression_level < 0 || pack_compression_level > Z_BEST_COMPRESSION)
                die("bad pack compression level %d", pack_compression_level);
+
+       if (!delta_search_threads)      /* --threads=0 means autodetect */
+               delta_search_threads = online_cpus();
+
 #ifdef NO_PTHREADS
        if (delta_search_threads != 1)
                warning("no threads support, ignoring --threads");
index 6fb98c333c22a67512516bbf047c2cac270a66ae..d9a769d19084587b397c50e9420843be38e89903 100644 (file)
@@ -7,5 +7,9 @@
 extern int online_cpus(void);
 extern int init_recursive_mutex(pthread_mutex_t*);
 
+#else
+
+#define online_cpus() 1
+
 #endif
 #endif /* THREAD_COMPAT_H */