From 5a6cd5153093ec233c5837bddaf852aabe2d872b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 22 Dec 2021 11:12:00 -0800 Subject: [PATCH] ircd::ctx::posix: Improve pthread version resolution for dlopen. --- ircd/ctx_posix.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ircd/ctx_posix.cc b/ircd/ctx_posix.cc index f5748bc04..f96cce5ea 100644 --- a/ircd/ctx_posix.cc +++ b/ircd/ctx_posix.cc @@ -75,6 +75,14 @@ ircd::ctx::posix::ctxs; // pthread supplement // +static const char *const +ircd_pthread_paths[] +{ + "libpthread.so.0", + "libpthread.so", + nullptr +}; + IRCD_WRAP(pthread_create, "__wrap_pthread_create", ( pthread_t *const thread, @@ -97,10 +105,11 @@ IRCD_WRAP(pthread_create, "__wrap_pthread_create", mutex }; - if(!ircd::ctx::posix::real_pthread) + auto p(ircd_pthread_paths[0]); + while(p && !ircd::ctx::posix::real_pthread) ircd::ctx::posix::real_pthread = //.reset ( - dlopen("libpthread.so", RTLD_LOCAL | RTLD_LAZY) + dlopen(p++, RTLD_LOCAL | RTLD_LAZY) ); }