Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-11-03 11:48:50 +0300
committerJunio C Hamano <gitster@pobox.com>2018-11-05 07:42:11 +0300
commit2179045fd02acca83127f8d15ccd0eeb70b17400 (patch)
tree9fdc037f4ae68e04712ddc63d77d5a2955471674 /name-hash.c
parentf5c4a9af45fa47130c730a5da87e030d040f000b (diff)
Clean up pthread_create() error handling
Normally pthread_create() rarely fails. But with new pthreads wrapper, pthread_create() will return ENOSYS on a system without thread support. Threaded code _is_ protected by HAVE_THREADS and pthread_create() should never run in the first place. But the situation could change in the future and bugs may sneak in. Make sure that all pthread_create() reports the error cause. While at there, mark these strings for translation if they aren't. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'name-hash.c')
-rw-r--r--name-hash.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/name-hash.c b/name-hash.c
index b3c9ac791d..623ca6923a 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -494,6 +494,7 @@ static inline void lazy_update_dir_ref_counts(
static void threaded_lazy_init_name_hash(
struct index_state *istate)
{
+ int err;
int nr_each;
int k_start;
int t;
@@ -526,8 +527,9 @@ static void threaded_lazy_init_name_hash(
if (k_start > istate->cache_nr)
k_start = istate->cache_nr;
td_dir_t->k_end = k_start;
- if (pthread_create(&td_dir_t->pthread, NULL, lazy_dir_thread_proc, td_dir_t))
- die("unable to create lazy_dir_thread");
+ err = pthread_create(&td_dir_t->pthread, NULL, lazy_dir_thread_proc, td_dir_t);
+ if (err)
+ die(_("unable to create lazy_dir thread: %s"), strerror(err));
}
for (t = 0; t < lazy_nr_dir_threads; t++) {
struct lazy_dir_thread_data *td_dir_t = td_dir + t;
@@ -547,13 +549,15 @@ static void threaded_lazy_init_name_hash(
*/
td_name->istate = istate;
td_name->lazy_entries = lazy_entries;
- if (pthread_create(&td_name->pthread, NULL, lazy_name_thread_proc, td_name))
- die("unable to create lazy_name_thread");
+ err = pthread_create(&td_name->pthread, NULL, lazy_name_thread_proc, td_name);
+ if (err)
+ die(_("unable to create lazy_name thread: %s"), strerror(err));
lazy_update_dir_ref_counts(istate, lazy_entries);
- if (pthread_join(td_name->pthread, NULL))
- die("unable to join lazy_name_thread");
+ err = pthread_join(td_name->pthread, NULL);
+ if (err)
+ die(_("unable to join lazy_name thread: %s"), strerror(err));
cleanup_dir_mutex();