diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-01-06 08:19:49 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-01-06 08:19:49 +0000 |
commit | 855cc0b1ea13c127721cde5d1c4f98c30242f3f0 (patch) | |
tree | b734b5a376b5302938c4648273089b99a92459d7 /lib/libc/gen | |
parent | a1e0aa17f16851229639dbb490fbdb1fad92a1f3 (diff) |
use thread-specific storage for the members list
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/getgrent.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index bf33339e90e..cfd5d1e44de 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -33,7 +33,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: getgrent.c,v 1.10 1999/09/03 16:23:18 millert Exp $"; +static char rcsid[] = "$OpenBSD: getgrent.c,v 1.11 2000/01/06 08:19:48 d Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -50,8 +50,8 @@ static char rcsid[] = "$OpenBSD: getgrent.c,v 1.10 1999/09/03 16:23:18 millert E #endif #include "thread_private.h" -_THREAD_PRIVATE_KEY(gr) -_THREAD_PRIVATE_MUTEX(gr) +_THREAD_PRIVATE_KEY(gr); +_THREAD_PRIVATE_MUTEX(gr); static FILE *_gr_fp; static struct group _gr_group; static int _gr_stayopen; @@ -59,10 +59,13 @@ static int grscan __P((int, gid_t, const char *, struct group *)); static int start_gr __P((void)); static void endgrent_basic __P((void)); +_THREAD_PRIVATE_KEY(gr_storage); +static struct group_storage { #define MAXGRP 200 -static char *members[MAXGRP]; + char *members[MAXGRP]; #define MAXLINELENGTH 1024 -static char line[MAXLINELENGTH]; + char line[MAXLINELENGTH]; +} gr_storage; #ifdef YP enum _ypmode { YPMODE_NONE, YPMODE_FULL, YPMODE_NAME }; @@ -225,6 +228,16 @@ grscan(search, gid, name, p_gr) int r; char *grname = (char *)NULL; #endif + char **members; + char *line; + struct group_storage *gs; + + /* Always use thread-specific storage for member data. */ + gs = (struct group_storage *)_THREAD_PRIVATE(gr_storage,gr_storage,NULL); + if (gs == NULL) + return 0; + members = gs->members; + line = gs->line; for (;;) { #ifdef YP |