From 431fc6465d32db324360e947bb55cf972e85cf84 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 10 Sep 2002 05:53:30 +0000 Subject: Fix some locking problems noted by Manuel. __getgrent() was always called under lock, but the callers did not share the same locks... -Erik --- libc/pwd_grp/grent.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libc/pwd_grp/grent.c') diff --git a/libc/pwd_grp/grent.c b/libc/pwd_grp/grent.c index 587fe0d93..9418ea937 100644 --- a/libc/pwd_grp/grent.c +++ b/libc/pwd_grp/grent.c @@ -40,6 +40,16 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; # define UNLOCK #endif +#ifdef __UCLIBC_HAS_THREADS__ +#include +extern pthread_mutex_t __getgrent_lock; +# define GRENT_LOCK pthread_mutex_lock(&__getgrent_lock) +# define GRENT_UNLOCK pthread_mutex_unlock(&__getgrent_lock); +#else +# define GRENT_LOCK +# define GRENT_UNLOCK +#endif + static int grp_fd = -1; static char *line_buff = NULL; static char **members = NULL; @@ -71,7 +81,9 @@ struct group *getgrent(void) UNLOCK; return NULL; } - r = __getgrent(grp_fd, line_buff, members); UNLOCK; + GRENT_LOCK; + r = __getgrent(grp_fd, line_buff, members); + GRENT_UNLOCK; return r; } -- cgit v1.2.3