]> granicus.if.org Git - procps-ng/commit
library: ensure thread safety via function substitutes
authorJim Warner <james.warner@comcast.net>
Tue, 28 Sep 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sat, 2 Oct 2021 02:55:31 +0000 (12:55 +1000)
commitca30741a30d2501b4d253e572d047e7d391be8a6
tree182217b5ff005e160920862e773c775cf1f419d4
parent23cfb7136636f2d522b31417892de79b011ad3e4
library: ensure thread safety via function substitutes

Even though we we had to abandon the master branch top
multi-thread effort and even though the newlib version
of a multi-threaded top provides no real benefit, that
whole exercise was not wasted. Rather, it has revealed
some deficiencies in our library which this addresses.

If two or more threads in the same address space tried
to use procps_loadavg or procps_uptime simultaneously,
there's a chance they would experience problems due to
thread-unsafe functions our library called internally.

So, this patch switches them for thread-safe versions.

[ along the way we will also make that procps_uptime ]
[ initialization of his 'up' & 'idle' variables mean ]
[ something by delaying the -ERANGE return a little. ]

Reference(s):
https://www.freelists.org/post/procps/a-few-more-patches,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/sysinfo.c
proc/uptime.c