Skip to content

Commit bebe171

Browse files
peffgitster
authored andcommitted
index-pack: drop type_cas mutex
The type_cas lock lost all of its callers in f08cbf6 (index-pack: make quantum of work smaller, 2020-09-08), so we can safely delete it. The compiler didn't alert us that the variable became unused, because we still call pthread_mutex_init() and pthread_mutex_destroy() on it. It's worth considering also whether that commit was in error to remove the use of the lock. Why don't we need it now, if we did before, as described in ab791dd (index-pack: fix race condition with duplicate bases, 2014-08-29)? I think the answer is that we now look at and assign the child_obj->real_type field in the main thread while holding the work_lock(). So we don't have to worry about racing with the worker threads. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cea6915 commit bebe171

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

builtin/index-pack.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ static pthread_mutex_t deepest_delta_mutex;
159159
#define deepest_delta_lock() lock_mutex(&deepest_delta_mutex)
160160
#define deepest_delta_unlock() unlock_mutex(&deepest_delta_mutex)
161161

162-
static pthread_mutex_t type_cas_mutex;
163-
#define type_cas_lock() lock_mutex(&type_cas_mutex)
164-
#define type_cas_unlock() unlock_mutex(&type_cas_mutex)
165-
166162
static pthread_key_t key;
167163

168164
static inline void lock_mutex(pthread_mutex_t *mutex)
@@ -186,7 +182,6 @@ static void init_thread(void)
186182
init_recursive_mutex(&read_mutex);
187183
pthread_mutex_init(&counter_mutex, NULL);
188184
pthread_mutex_init(&work_mutex, NULL);
189-
pthread_mutex_init(&type_cas_mutex, NULL);
190185
if (show_stat)
191186
pthread_mutex_init(&deepest_delta_mutex, NULL);
192187
pthread_key_create(&key, NULL);
@@ -209,7 +204,6 @@ static void cleanup_thread(void)
209204
pthread_mutex_destroy(&read_mutex);
210205
pthread_mutex_destroy(&counter_mutex);
211206
pthread_mutex_destroy(&work_mutex);
212-
pthread_mutex_destroy(&type_cas_mutex);
213207
if (show_stat)
214208
pthread_mutex_destroy(&deepest_delta_mutex);
215209
for (i = 0; i < nr_threads; i++)

0 commit comments

Comments
 (0)