diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-09-10 05:53:30 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-09-10 05:53:30 +0000 |
commit | 431fc6465d32db324360e947bb55cf972e85cf84 (patch) | |
tree | 48f6b77281a4d10e929ad35c075e54464ebe7785 /libc/pwd_grp/grent.c | |
parent | bee4f83a21cf7ca9937f7c69020cd44e076c9591 (diff) |
Fix some locking problems noted by Manuel. __getgrent() was always
called under lock, but the callers did not share the same locks...
-Erik
Diffstat (limited to 'libc/pwd_grp/grent.c')
-rw-r--r-- | libc/pwd_grp/grent.c | 14 |
1 files changed, 13 insertions, 1 deletions
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 <pthread.h> +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; } |