]> granicus.if.org Git - procps-ng/commitdiff
library: extend thread safety to more static variables
authorJim Warner <james.warner@comcast.net>
Fri, 22 Oct 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Mon, 25 Oct 2021 10:51:18 +0000 (21:51 +1100)
In the commit referenced below, a '__thread' attribute
was added to numerous static variables to protect them
from concurrent access conflicts with multi-threading.

Unfortunately, that patch did not go quite far enough.

So, this commit adds a few more '__thread' qualifiers.

Reference(s):
commit 23cfb7136636f2d522b31417892de79b011ad3e4

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/devname.c
proc/pwcache.c
proc/readproc.c

index 325877f964550b9e9facc80767a3275086d33d5b..de9d0bb7fad712c6628b700bcc7841251bf66cb1 100644 (file)
@@ -60,7 +60,7 @@ typedef struct tty_map_node {
   char name[16];
 } tty_map_node;
 
-static tty_map_node *tty_map = NULL;
+static __thread tty_map_node *tty_map = NULL;
 
 /* Load /proc/tty/drivers for device name mapping use. */
 static void load_drivers(void){
index db9b16ae0beb49421635699905794e515969ab5a..7baab1b2f28c483ecd5d31003bc884f561370884 100644 (file)
@@ -38,7 +38,7 @@
 
 static char ERRname[] = "?";
 
-static struct pwbuf {
+static __thread struct pwbuf {
     struct pwbuf *next;
     uid_t uid;
     char name[P_G_SZ];
@@ -67,7 +67,7 @@ char *pwcache_get_user(uid_t uid) {
     return((*p)->name);
 }
 
-static struct grpbuf {
+static __thread struct grpbuf {
     struct grpbuf *next;
     gid_t gid;
     char name[P_G_SZ];
index edcd016bc1a975823e156da2207146273917769b..27e4e381acb4a16e8bc6b11521898f806dc80166 100644 (file)
@@ -58,8 +58,8 @@ extern void __cyg_profile_func_enter(void*,void*);
 
 // utility buffers of MAX_BUFSZ bytes each, available to
 // any function following an openproc() call
-static char *src_buffer,
-            *dst_buffer;
+static __thread char *src_buffer,
+                     *dst_buffer;
 #define MAX_BUFSZ 1024*64*2
 
 // dynamic 'utility' buffer support for file2str() calls