mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 892201: replace SPS signal handler completion busy loop with POSIX semaphore. r=benwa
--HG-- extra : rebase_source : 48bfcc1a352ae600dd1294d5b5e122ad0c58a745
This commit is contained in:
parent
5a1c4394b2
commit
54bfab9cb0
@ -53,6 +53,7 @@
|
||||
#include <sys/stat.h> // open
|
||||
#include <fcntl.h> // open
|
||||
#include <unistd.h> // sysconf
|
||||
#include <semaphore.h>
|
||||
#ifdef __GLIBC__
|
||||
#include <execinfo.h> // backtrace, backtrace_symbols
|
||||
#endif // def __GLIBC__
|
||||
@ -62,6 +63,7 @@
|
||||
#include "platform.h"
|
||||
#include "GeckoProfilerImpl.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "ProfileEntry.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "TableTicker.h"
|
||||
@ -140,7 +142,8 @@ struct SamplerRegistry {
|
||||
|
||||
Sampler *SamplerRegistry::sampler = NULL;
|
||||
|
||||
static ThreadProfile* sCurrentThreadProfile = NULL;
|
||||
static mozilla::Atomic<ThreadProfile*> sCurrentThreadProfile;
|
||||
static sem_t sSignalHandlingDone;
|
||||
|
||||
static void ProfilerSaveSignalHandler(int signal, siginfo_t* info, void* context) {
|
||||
Sampler::GetActiveSampler()->RequestSave();
|
||||
@ -204,6 +207,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
||||
Sampler::GetActiveSampler()->Tick(sample);
|
||||
|
||||
sCurrentThreadProfile = NULL;
|
||||
sem_post(&sSignalHandlingDone);
|
||||
}
|
||||
|
||||
int tgkill(pid_t tgid, pid_t tid, int signalno) {
|
||||
@ -270,8 +274,7 @@ static void* SignalSender(void* arg) {
|
||||
}
|
||||
|
||||
// Wait for the signal handler to run before moving on to the next one
|
||||
while (sCurrentThreadProfile)
|
||||
sched_yield();
|
||||
sem_wait(&sSignalHandlingDone);
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,6 +307,13 @@ void Sampler::Start() {
|
||||
|
||||
SamplerRegistry::AddActiveSampler(this);
|
||||
|
||||
// Initialize signal handler communication
|
||||
sCurrentThreadProfile = NULL;
|
||||
if (sem_init(&sSignalHandlingDone, /* pshared: */ 0, /* value: */ 0) != 0) {
|
||||
LOG("Error initializing semaphore");
|
||||
return;
|
||||
}
|
||||
|
||||
// Request profiling signals.
|
||||
LOG("Request signal");
|
||||
struct sigaction sa;
|
||||
|
Loading…
Reference in New Issue
Block a user