diff --git a/import.c b/import.c
index 011ff6d..ce45d78 100644
--- a/import.c
+++ b/import.c
@@ -122,9 +122,12 @@ strcommonendingwith(const char *a, const char *b, char endc)
static void *worker(void *arg)
/* consume masters off the queue */
{
+ rev_list *local_head = NULL, **local_tail = &local_head;
+ cvstime_t local_skew_vulnerable = 0;
+ int local_total_revisions = 0;
+
rev_list *rl;
analysis_t out = {0, 0};
- bool keepgoing = true;
for (;;)
{
@@ -136,40 +139,47 @@ static void *worker(void *arg)
pthread_mutex_lock(&enqueue_mutex);
#endif /* THREADS */
if (fn_head == NULL)
- keepgoing = false;
- else
- {
- fn = fn_head;
- fn_head = fn_head->next;
- filename = fn->file;
- free((rev_filename *)fn);
- }
+ break;
+ fn = fn_head;
+ fn_head = fn_head->next;
+ filename = fn->file;
+ free((rev_filename *)fn);
+ progress_jump(++load_current_file);
#ifdef THREADS
if (threads > 1)
pthread_mutex_unlock(&enqueue_mutex);
#endif /* THREADS */
- if (!keepgoing)
- return(NULL);
/* process it */
rl = rev_list_file(filename, &out);
- /* pass it to the next stage */
+ /* accumulate data */
+ *local_tail = rl;
+ total_revisions += out.total_revisions;
+ if (out.skew_vulnerable > local_skew_vulnerable)
+ local_skew_vulnerable = out.skew_vulnerable;
+ local_tail = &rl->next;
+ }
+
#ifdef THREADS
- if (threads > 1)
- pthread_mutex_lock(&revlist_mutex);
+ if (threads > 1)
+ {
+ pthread_mutex_unlock(&enqueue_mutex);
+ pthread_mutex_lock(&revlist_mutex);
+ }
#endif /* THREADS */
- progress_jump(++load_current_file);
- *tail = rl;
- total_revisions += out.total_revisions;
- if (out.skew_vulnerable > skew_vulnerable)
- skew_vulnerable = out.skew_vulnerable;
- tail = (volatile rev_list **)&rl->next;
+ /* pass it to the next stage */
+ progress_jump(++load_current_file);
+ *tail = local_head;
+ tail = (volatile rev_list**)local_tail;
+ total_revisions += local_total_revisions;
+ if (local_skew_vulnerable > skew_vulnerable)
+ skew_vulnerable = local_skew_vulnerable;
#ifdef THREADS
- if (threads > 1)
- pthread_mutex_unlock(&revlist_mutex);
+ if (threads > 1)
+ pthread_mutex_unlock(&revlist_mutex);
#endif /* THREADS */
- }
+ return(NULL);
}
rev_list *analyze_masters(int argc, char *argv[],