Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148451271
D55310.id171973.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D55310.id171973.diff
View Options
diff --git a/lib/libc/rpc/getnetconfig.c b/lib/libc/rpc/getnetconfig.c
--- a/lib/libc/rpc/getnetconfig.c
+++ b/lib/libc/rpc/getnetconfig.c
@@ -118,7 +118,6 @@
#define NC_INVALID 0
-static int *__nc_error(void);
static int parse_ncp(char *, struct netconfig *);
static struct netconfig *dup_ncp(struct netconfig *);
@@ -129,46 +128,10 @@
static struct netconfig_info ni = { 0, 0, NULL, NULL};
static mutex_t ni_lock = MUTEX_INITIALIZER;
-static thread_key_t nc_key;
-static once_t nc_once = ONCE_INITIALIZER;
-static int nc_key_error;
-
-static void
-nc_key_init(void)
-{
-
- nc_key_error = thr_keycreate(&nc_key, free);
-}
+static _Thread_local int nc_error = 0;
#define MAXNETCONFIGLINE 1000
-static int *
-__nc_error(void)
-{
- static int nc_error = 0;
- int *nc_addr;
-
- /*
- * Use the static `nc_error' if we are the main thread
- * (including non-threaded programs), or if an allocation
- * fails.
- */
- if (thr_main())
- return (&nc_error);
- if (thr_once(&nc_once, nc_key_init) != 0 || nc_key_error != 0)
- return (&nc_error);
- if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) {
- nc_addr = (int *)malloc(sizeof (int));
- if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
- free(nc_addr);
- return (&nc_error);
- }
- *nc_addr = 0;
- }
- return (nc_addr);
-}
-
-#define nc_error (*(__nc_error()))
/*
* A call to setnetconfig() establishes a /etc/netconfig "session". A session
* "handle" is returned on a successful call. At the start of a session (after
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 18, 11:46 PM (3 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28815621
Default Alt Text
D55310.id171973.diff (1 KB)
Attached To
Mode
D55310: getnetconfig: make nc_error a thread local variable
Attached
Detach File
Event Timeline
Log In to Comment