Initialize global mutex in a thread-safe manner
authorNiklas Haas <git@haasn.dev>
Mon, 8 Nov 2021 13:47:32 +0000 (14:47 +0100)
committerNiklas Haas <git@haasn.dev>
Mon, 8 Nov 2021 13:47:32 +0000 (14:47 +0100)
commit3971424207e27a662d4416eedfb68e18ff287350
treee3e8e5bca34e8f32c3e4e1f53e933cedd5b3ab1d
parenteb92526d5e04572fdf1d15d2f3ae10a967c2f46f
Initialize global mutex in a thread-safe manner

Currently, ShInitialize() and friends call glslang::InitGlobalLock()
which *overwrites* the global mutex. As such, even though it ostensibly
takes a mutex, this function is actually completely thread-unsafe.

Fix it by using pthread_once to ensure the mutex is only initialized
once, and then never again.
glslang/OSDependent/Unix/ossource.cpp