@@ -78,6 +78,7 @@ static int nr_threads;
78
78
static int from_stdin ;
79
79
static int strict ;
80
80
static int verbose ;
81
+ static int show_stat ;
81
82
82
83
static struct progress * progress ;
83
84
@@ -108,6 +109,10 @@ static pthread_mutex_t work_mutex;
108
109
#define work_lock () lock_mutex(&work_mutex)
109
110
#define work_unlock () unlock_mutex(&work_mutex)
110
111
112
+ static pthread_mutex_t deepest_delta_mutex ;
113
+ #define deepest_delta_lock () lock_mutex(&deepest_delta_mutex)
114
+ #define deepest_delta_unlock () unlock_mutex(&deepest_delta_mutex)
115
+
111
116
static pthread_key_t key ;
112
117
113
118
static inline void lock_mutex (pthread_mutex_t * mutex )
@@ -130,6 +135,8 @@ static void init_thread(void)
130
135
init_recursive_mutex (& read_mutex );
131
136
pthread_mutex_init (& counter_mutex , NULL );
132
137
pthread_mutex_init (& work_mutex , NULL );
138
+ if (show_stat )
139
+ pthread_mutex_init (& deepest_delta_mutex , NULL );
133
140
pthread_key_create (& key , NULL );
134
141
thread_data = xcalloc (nr_threads , sizeof (* thread_data ));
135
142
threads_active = 1 ;
@@ -143,6 +150,8 @@ static void cleanup_thread(void)
143
150
pthread_mutex_destroy (& read_mutex );
144
151
pthread_mutex_destroy (& counter_mutex );
145
152
pthread_mutex_destroy (& work_mutex );
153
+ if (show_stat )
154
+ pthread_mutex_destroy (& deepest_delta_mutex );
146
155
pthread_key_delete (key );
147
156
free (thread_data );
148
157
}
@@ -158,6 +167,9 @@ static void cleanup_thread(void)
158
167
#define work_lock ()
159
168
#define work_unlock ()
160
169
170
+ #define deepest_delta_lock ()
171
+ #define deepest_delta_unlock ()
172
+
161
173
#endif
162
174
163
175
@@ -833,9 +845,13 @@ static void resolve_delta(struct object_entry *delta_obj,
833
845
void * base_data , * delta_data ;
834
846
835
847
delta_obj -> real_type = base -> obj -> real_type ;
836
- delta_obj -> delta_depth = base -> obj -> delta_depth + 1 ;
837
- if (deepest_delta < delta_obj -> delta_depth )
838
- deepest_delta = delta_obj -> delta_depth ;
848
+ if (show_stat ) {
849
+ delta_obj -> delta_depth = base -> obj -> delta_depth + 1 ;
850
+ deepest_delta_lock ();
851
+ if (deepest_delta < delta_obj -> delta_depth )
852
+ deepest_delta = delta_obj -> delta_depth ;
853
+ deepest_delta_unlock ();
854
+ }
839
855
delta_obj -> base_object_no = base -> obj - objects ;
840
856
delta_data = get_data_from_pack (delta_obj );
841
857
base_data = get_base_data (base );
@@ -951,8 +967,10 @@ static void *threaded_second_pass(void *data)
951
967
set_thread_data (data );
952
968
for (;;) {
953
969
int i ;
954
- work_lock ();
970
+ counter_lock ();
955
971
display_progress (progress , nr_resolved_deltas );
972
+ counter_unlock ();
973
+ work_lock ();
956
974
while (nr_dispatched < nr_objects &&
957
975
is_delta_type (objects [nr_dispatched ].type ))
958
976
nr_dispatched ++ ;
@@ -1465,7 +1483,7 @@ static void show_pack_info(int stat_only)
1465
1483
1466
1484
int cmd_index_pack (int argc , const char * * argv , const char * prefix )
1467
1485
{
1468
- int i , fix_thin_pack = 0 , verify = 0 , stat_only = 0 , stat = 0 ;
1486
+ int i , fix_thin_pack = 0 , verify = 0 , stat_only = 0 ;
1469
1487
const char * curr_pack , * curr_index ;
1470
1488
const char * index_name = NULL , * pack_name = NULL ;
1471
1489
const char * keep_name = NULL , * keep_msg = NULL ;
@@ -1498,10 +1516,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1498
1516
verify = 1 ;
1499
1517
} else if (!strcmp (arg , "--verify-stat" )) {
1500
1518
verify = 1 ;
1501
- stat = 1 ;
1519
+ show_stat = 1 ;
1502
1520
} else if (!strcmp (arg , "--verify-stat-only" )) {
1503
1521
verify = 1 ;
1504
- stat = 1 ;
1522
+ show_stat = 1 ;
1505
1523
stat_only = 1 ;
1506
1524
} else if (!strcmp (arg , "--keep" )) {
1507
1525
keep_msg = "" ;
@@ -1609,7 +1627,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1609
1627
if (strict )
1610
1628
check_objects ();
1611
1629
1612
- if (stat )
1630
+ if (show_stat )
1613
1631
show_pack_info (stat_only );
1614
1632
1615
1633
idx_objects = xmalloc ((nr_objects ) * sizeof (struct pack_idx_entry * ));
0 commit comments