]> granicus.if.org Git - procps-ng/commit
library: ensure thread safety for all static variables
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)
commit23cfb7136636f2d522b31417892de79b011ad3e4
treecaf411c28ea8f69494f7d97defc2dc0b8b4413f9
parent69978e365043f27305e487709474947bb377084d
library: ensure thread safety for all static variables

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 access the same api simultaneously, there is a good
chance some function-local static variables will yield
some of those renowned unpredictable results. So, this
patch protects them with the '__thread' storage class.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/devname.c
proc/escape.c
proc/meminfo.c
proc/pids.c
proc/readproc.c
proc/slabinfo.c
proc/stat.c
proc/sysinfo.c
proc/vmstat.c
proc/wchan.c