mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
nsswitch: remove winbind_nss_mutex
We're now thread-safe by using TLS, so the global lock isn't needed anymore. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Thu Jan 5 12:34:35 UTC 2023 on sn-devel-184
This commit is contained in:
parent
642a4452ce
commit
316b8fa4a8
@ -25,10 +25,6 @@
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
static pthread_mutex_t winbind_nss_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
|
||||
/* Maximum number of users to pass back over the unix domain socket
|
||||
per call. This is not a static limit on the total number of users
|
||||
or groups returned in total. */
|
||||
@ -370,10 +366,6 @@ _nss_winbind_setpwent(void)
|
||||
fprintf(stderr, "[%5d]: setpwent\n", getpid());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
if (num_pw_cache > 0) {
|
||||
ndx_pw_cache = num_pw_cache = 0;
|
||||
winbindd_free_response(&getpwent_response);
|
||||
@ -386,9 +378,6 @@ _nss_winbind_setpwent(void)
|
||||
nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -403,10 +392,6 @@ _nss_winbind_endpwent(void)
|
||||
fprintf(stderr, "[%5d]: endpwent\n", getpid());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
if (num_pw_cache > 0) {
|
||||
ndx_pw_cache = num_pw_cache = 0;
|
||||
winbindd_free_response(&getpwent_response);
|
||||
@ -419,10 +404,6 @@ _nss_winbind_endpwent(void)
|
||||
nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -441,10 +422,6 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
|
||||
fprintf(stderr, "[%5d]: getpwent\n", getpid());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
/* Return an entry from the cache if we have one, or if we are
|
||||
called again because we exceeded our static buffer. */
|
||||
|
||||
@ -517,9 +494,6 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
|
||||
nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -539,10 +513,6 @@ _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer,
|
||||
fprintf(stderr, "[%5d]: getpwuid_r %d\n", getpid(), (unsigned int)uid);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
/* If our static buffer needs to be expanded we are called again */
|
||||
if (!keep_response || uid != response.data.pw.pw_uid) {
|
||||
|
||||
@ -596,10 +566,6 @@ _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer,
|
||||
(unsigned int)uid, nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -618,10 +584,6 @@ _nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer,
|
||||
fprintf(stderr, "[%5d]: getpwnam_r %s\n", getpid(), name);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
/* If our static buffer needs to be expanded we are called again */
|
||||
|
||||
if (!keep_response || strcmp(name,response.data.pw.pw_name) != 0) {
|
||||
@ -677,10 +639,6 @@ _nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer,
|
||||
name, nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -704,10 +662,6 @@ _nss_winbind_setgrent(void)
|
||||
fprintf(stderr, "[%5d]: setgrent\n", getpid());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
if (num_gr_cache > 0) {
|
||||
ndx_gr_cache = num_gr_cache = 0;
|
||||
winbindd_free_response(&getgrent_response);
|
||||
@ -720,10 +674,6 @@ _nss_winbind_setgrent(void)
|
||||
nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -738,10 +688,6 @@ _nss_winbind_endgrent(void)
|
||||
fprintf(stderr, "[%5d]: endgrent\n", getpid());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
if (num_gr_cache > 0) {
|
||||
ndx_gr_cache = num_gr_cache = 0;
|
||||
winbindd_free_response(&getgrent_response);
|
||||
@ -754,10 +700,6 @@ _nss_winbind_endgrent(void)
|
||||
nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -777,10 +719,6 @@ winbind_getgrent(enum winbindd_cmd cmd,
|
||||
fprintf(stderr, "[%5d]: getgrent\n", getpid());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
/* Return an entry from the cache if we have one, or if we are
|
||||
called again because we exceeded our static buffer. */
|
||||
|
||||
@ -862,10 +800,6 @@ winbind_getgrent(enum winbindd_cmd cmd,
|
||||
nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -903,10 +837,6 @@ _nss_winbind_getgrnam_r(const char *name,
|
||||
fprintf(stderr, "[%5d]: getgrnam %s\n", getpid(), name);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
/* If our static buffer needs to be expanded we are called again */
|
||||
/* Or if the stored response group name differs from the request. */
|
||||
|
||||
@ -967,10 +897,6 @@ _nss_winbind_getgrnam_r(const char *name,
|
||||
name, nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -991,10 +917,6 @@ _nss_winbind_getgrgid_r(gid_t gid,
|
||||
fprintf(stderr, "[%5d]: getgrgid %d\n", getpid(), gid);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
/* If our static buffer needs to be expanded we are called again */
|
||||
/* Or if the stored response group name differs from the request. */
|
||||
|
||||
@ -1054,9 +976,6 @@ _nss_winbind_getgrgid_r(gid_t gid,
|
||||
(unsigned int)gid, nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1078,10 +997,6 @@ _nss_winbind_initgroups_dyn(const char *user, gid_t group, long int *start,
|
||||
user, group);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
ZERO_STRUCT(request);
|
||||
ZERO_STRUCT(response);
|
||||
|
||||
@ -1171,9 +1086,5 @@ _nss_winbind_initgroups_dyn(const char *user, gid_t group, long int *start,
|
||||
user, nss_err_str(ret), ret);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock(&winbind_nss_mutex);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user