process-util: use our usual tristate semantics for is_main_thread()

While at it, _unlikely_ is dropped, as requested in
https://github.com/systemd/systemd/pull/35242#discussion_r1880096233
This commit is contained in:
Mike Yuan
2024-12-11 14:44:07 +01:00
parent e18768751e
commit 07612aab66
+4 -4
View File
@@ -1226,12 +1226,12 @@ int pid_from_same_root_fs(pid_t pid) {
}
bool is_main_thread(void) {
static thread_local int cached = 0;
static thread_local int cached = -1;
if (_unlikely_(cached == 0))
cached = getpid_cached() == gettid() ? 1 : -1;
if (cached < 0)
cached = getpid_cached() == gettid();
return cached > 0;
return cached;
}
bool oom_score_adjust_is_valid(int oa) {