Merge pull request #1085 from ajbeamon/thread-safety-fixes
Thread safety fixes
This commit is contained in:
commit
a67077f06c
|
@ -2594,13 +2594,13 @@ extern volatile size_t net2backtraces_max;
|
||||||
extern volatile bool net2backtraces_overflow;
|
extern volatile bool net2backtraces_overflow;
|
||||||
extern volatile int net2backtraces_count;
|
extern volatile int net2backtraces_count;
|
||||||
extern volatile double net2liveness;
|
extern volatile double net2liveness;
|
||||||
extern volatile int profilingEnabled;
|
extern volatile thread_local int profilingEnabled;
|
||||||
extern void initProfiling();
|
extern void initProfiling();
|
||||||
|
|
||||||
volatile thread_local bool profileThread = false;
|
volatile thread_local bool profileThread = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile int profilingEnabled = 1;
|
volatile thread_local int profilingEnabled = 1;
|
||||||
|
|
||||||
void setProfilingEnabled(int enabled) {
|
void setProfilingEnabled(int enabled) {
|
||||||
profilingEnabled = enabled;
|
profilingEnabled = enabled;
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include "flow/Platform.h"
|
#include "flow/Platform.h"
|
||||||
|
|
||||||
extern volatile int profilingEnabled;
|
extern volatile thread_local int profilingEnabled;
|
||||||
|
|
||||||
static uint64_t gettid() { return syscall(__NR_gettid); }
|
static uint64_t gettid() { return syscall(__NR_gettid); }
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,14 @@ int64_t dl_iterate_phdr_calls = 0;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
static bool phdr_cache_initialized = false;
|
static bool phdr_cache_initialized = false;
|
||||||
static std::vector< std::vector<uint8_t> > phdr_cache;
|
static std::vector< std::vector<uint8_t> > phdr_cache;
|
||||||
|
|
||||||
static int (*chain_dl_iterate_phdr)(
|
static int (*chain_dl_iterate_phdr)(
|
||||||
int (*callback) (struct dl_phdr_info *info, size_t size, void *data),
|
int (*callback) (struct dl_phdr_info *info, size_t size, void *data),
|
||||||
void *data) = 0;
|
void *data) = nullptr;
|
||||||
|
|
||||||
static int phdr_cache_add( struct dl_phdr_info *info, size_t size, void *data ) {
|
static int phdr_cache_add( struct dl_phdr_info *info, size_t size, void *data ) {
|
||||||
phdr_cache.push_back( std::vector<uint8_t>((uint8_t*)info, (uint8_t*)info + size) );
|
phdr_cache.push_back( std::vector<uint8_t>((uint8_t*)info, (uint8_t*)info + size) );
|
||||||
|
@ -39,10 +40,14 @@ static int phdr_cache_add( struct dl_phdr_info *info, size_t size, void *data )
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initChain() {
|
static void initChain() {
|
||||||
|
static std::once_flag flag;
|
||||||
|
|
||||||
// Ensure that chain_dl_iterate_phdr points to the "real" function that we are overriding
|
// Ensure that chain_dl_iterate_phdr points to the "real" function that we are overriding
|
||||||
*(void**)&chain_dl_iterate_phdr = dlsym(RTLD_NEXT, "dl_iterate_phdr");
|
std::call_once(flag, [](){ *(void**)&chain_dl_iterate_phdr = dlsym(RTLD_NEXT, "dl_iterate_phdr"); });
|
||||||
if (!chain_dl_iterate_phdr)
|
|
||||||
|
if (!chain_dl_iterate_phdr) {
|
||||||
criticalError(FDB_EXIT_ERROR, "SignalSafeUnwindError", "Unable to find dl_iterate_phdr symbol");
|
criticalError(FDB_EXIT_ERROR, "SignalSafeUnwindError", "Unable to find dl_iterate_phdr symbol");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSignalSafeUnwind() {
|
void initSignalSafeUnwind() {
|
||||||
|
|
Loading…
Reference in New Issue