From 73b73e781ee079a6d0cae568cfaa63230ef5360c Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 19 Jul 2020 23:07:43 +0900 Subject: [PATCH] double check map->done when joining thread Sometimes a thread exit after checking map->done which was false and before DosWaitThread(). As a result, DosWaitThread() fails because the thread does not exist anymore. Then, pthread_join() returns ESRCH. However, this is wrong! Because the thread ended already without any problems. Instead, check map->done once more to check the thread ended already. git-status fails on vlc because of this, complaining like this: fatal: unable to join threaded lstat --- src/my_os2thread.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/my_os2thread.c b/src/my_os2thread.c index 427bc3a..d92fe20 100644 --- a/src/my_os2thread.c +++ b/src/my_os2thread.c @@ -301,8 +301,11 @@ int pthread_join( pthread_t thread, void **status) // (by DosKillThread in LIBC which delivers Posix signals this way) if (rc == ERROR_INTERRUPT) continue; - if (rc == ERROR_INVALID_THREADID) + if (rc == ERROR_INVALID_THREADID) { + if (map->done) + break; return ESRCH; + } if (rc != NO_ERROR) return EINVAL; break; -- 2.22.0