From: Alain Spineux Date: Fri, 3 Sep 2021 15:07:18 +0000 (+0200) Subject: Extend lockmgr to allow the use of destructor in pthread_key_create() X-Git-Tag: Release-11.3.2~294 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d56aa41a1af6acbc761cf73e2ea312697777bd3c;p=thirdparty%2Fbacula.git Extend lockmgr to allow the use of destructor in pthread_key_create() - if a destructor use a lock then the lockmgr cannot find the thread (that is being destructed) anymore and fail to update the list for this thread. - instead we check that we have a thread alive before to update it. - TODO maybe we should also do the same check for other use of "self" in lockmgr.c --- diff --git a/bacula/src/lib/lockmgr.c b/bacula/src/lib/lockmgr.c index 4323e5226..f9f17485d 100644 --- a/bacula/src/lib/lockmgr.c +++ b/bacula/src/lib/lockmgr.c @@ -1022,9 +1022,9 @@ int bthread_mutex_unlock_p(bthread_mutex_t *m, const char *file, int line) int bthread_mutex_lock_p(pthread_mutex_t *m, const char *file, int line) { lmgr_thread_t *self = lmgr_get_thread_info(); - self->pre_P(m, 0, file, line); + if (self) self->pre_P(m, 0, file, line); lmgr_p(m); - self->post_P(); + if (self) self->post_P(); return 0; } @@ -1035,7 +1035,7 @@ int bthread_mutex_lock_p(pthread_mutex_t *m, const char *file, int line) int bthread_mutex_unlock_p(pthread_mutex_t *m, const char *file, int line) { lmgr_thread_t *self = lmgr_get_thread_info(); - self->do_V(m, file, line); + if (self) self->do_V(m, file, line); lmgr_v(m); return 0; }