diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2020-04-15 16:56:30 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2020-04-15 17:03:03 +0200 |
commit | 654d5055ab6069765327e78a176608848a15f1ab (patch) | |
tree | c98a6f5b4a2a525c63d14a961fb5b861ff1a1ec1 /vespalog/src | |
parent | 2cfb6199fc7f3286124cdb2631fbf90bc39ddea6 (diff) |
Handle noninteger pthread_t.
Diffstat (limited to 'vespalog/src')
-rw-r--r-- | vespalog/src/vespa/log/log.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/vespalog/src/vespa/log/log.cpp b/vespalog/src/vespa/log/log.cpp index 635d982f529..2e19dda504c 100644 --- a/vespalog/src/vespa/log/log.cpp +++ b/vespalog/src/vespa/log/log.cpp @@ -39,6 +39,14 @@ char Logger::_hostname[1024] = { '\0'}; char Logger::_serviceName[1024] = {'\0' }; ControlFile *Logger::_controlFile = 0; +static inline unsigned long gettid(const void *tid) { + return reinterpret_cast<uint64_t>(tid) >> 3; +} + +static inline unsigned long gettid(unsigned long tid) { + return tid; +} + void Logger::ensureControlName() { @@ -265,7 +273,7 @@ void Logger::doLogCore(uint64_t timestamp, LogLevel level, // threads, only showing the least significant bits will hopefully // distinguish between all threads in your application. Alter later if // found to be too inaccurate. - int32_t tid = (fakePid ? -1 : pthread_self() % 0xffff); + int32_t tid = (fakePid ? -1 : gettid(pthread_self()) % 0xffff); if (_target->makeHumanReadable()) { time_t secs = static_cast<time_t>(timestamp / 1000000); |