Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release-src > by-pkgid > 932f19527b543f9e58dd93f1062f6111 > files > 4

nss_postgresql-0.6.1-10.mga5.src.rpm

Index: group.c
===================================================================
--- group.c
+++ group.c	2012-08-13 22:27:09.227530025 +0200
@@ -14,7 +14,7 @@
 #include "nss_setup.h"
 
 /* Locks the static variables in this file.  */
-static pthread_mutex_t _nss_pg_gr_lock;
+static pthread_mutex_t lock;
 
 /* global var : the connection handler */
 static PGconn *pgconn_grp = NULL;
@@ -337,22 +337,24 @@
 {
 	enum nss_status status;
 
-	__libc_lock_lock (_nss_pg_gr_lock);
-	status = internal_setgrent ();
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
+    status = internal_setgrent ();
 	if (status == NSS_STATUS_SUCCESS) {
 	   status=cursor_begin();
 	}
-	__libc_lock_unlock (_nss_pg_gr_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }
 
 
 enum nss_status _nss_pgsql_endgrent (void)
 {
-	__libc_lock_lock (_nss_pg_gr_lock);
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
 	cursor_stop();
 	internal_endgrent ();
-	__libc_lock_unlock (_nss_pg_gr_lock);
+    pthread_mutex_unlock(&lock);
 	return NSS_STATUS_SUCCESS;
 }
 
@@ -362,9 +364,10 @@
 {
 	enum nss_status status;
 
-	__libc_lock_lock (_nss_pg_gr_lock);
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
 	status = gr_lookup (NULL, "ent", grp, buffer, buflen, errnop);
-	__libc_lock_unlock (_nss_pg_gr_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }
 
@@ -374,7 +377,8 @@
 {
 	enum nss_status status=NSS_STATUS_UNAVAIL;
 
-	__libc_lock_lock (_nss_pg_gr_lock);
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
 	status = internal_setgrent ();
 	if (status == NSS_STATUS_SUCCESS) {
 		status = gr_lookup (name, "nam", grp, buffer, buflen, errnop);
@@ -383,7 +387,7 @@
 #if DEBUG>2
 	_nss_pgsql_log(LOG_DEBUG,"getgrnam(%s) return %d",name,status);
 #endif	
-	__libc_lock_unlock (_nss_pg_gr_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }
 
@@ -396,7 +400,8 @@
    char gidstr[21];	
 
 	snprintf (gidstr, sizeof gidstr, "%d", gid);
-	__libc_lock_lock (_nss_pg_gr_lock);
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
 	status = internal_setgrent ();
 	if (status == NSS_STATUS_SUCCESS) {
 		status = gr_lookup (gidstr, "gid", grp, buffer, buflen, errnop);
@@ -405,6 +410,6 @@
 #if DEBUG>2
 	_nss_pgsql_log(LOG_DEBUG,"getgrgid(%d) return %d",gid,status);
 #endif	
-	__libc_lock_unlock (_nss_pg_gr_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }
Index: nss_setup.h
===================================================================
--- nss_setup.h
+++ nss_setup.h	2012-08-13 22:33:25.291774547 +0200
@@ -18,7 +18,7 @@
  * 6 : LOG_DEBUG dump internal structures
  */
 
-#define DEBUG	1
+#define DEBUG	6
 
 /*
  * set MAXSERVERS to the number of database servers you wish
Index: passwd.c
===================================================================
--- passwd.c
+++ passwd.c	2012-08-13 22:34:12.223584456 +0200
@@ -12,9 +12,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include "nss_setup.h"
+#include <pthread.h>
 
 /* Locks the static variables in this file.  */
-static pthread_mutex_t _nss_pg_lock;
+static pthread_mutex_t lock;
 
 /* global var : the connection handler */
 static PGconn *pgconn = NULL;
@@ -311,21 +312,23 @@
 enum nss_status _nss_pgsql_setpwent (void) {
    enum nss_status status;
 
-   __libc_lock_lock (_nss_pg_lock);
+   if (pthread_mutex_lock(&lock))
+       return NSS_STATUS_TRYAGAIN;
    status = internal_setpwent ();
    if (status == NSS_STATUS_SUCCESS) {
       status = cursor_begin();
    }
-   __libc_lock_unlock (_nss_pg_lock);
+   pthread_mutex_unlock(&lock);
    return status;
 }
 
 enum nss_status _nss_pgsql_endpwent (void) {
 
-   __libc_lock_lock (_nss_pg_lock);
+   if (pthread_mutex_lock(&lock))
+       return NSS_STATUS_TRYAGAIN;
    cursor_close();
    internal_endpwent();
-   __libc_lock_unlock (_nss_pg_lock);
+   pthread_mutex_unlock(&lock);
    return NSS_STATUS_SUCCESS;
 }
 
@@ -333,7 +336,8 @@
    struct passwd *pwd, char *buffer, size_t buflen, int *errnop) {
   enum nss_status status;
 
-  __libc_lock_lock (_nss_pg_lock);
+  if (pthread_mutex_lock(&lock))
+     return NSS_STATUS_TRYAGAIN;
   status = internal_setpwent ();
   if (status == NSS_STATUS_SUCCESS) {
      status = lookup (name, "nam", pwd, buffer, buflen, errnop);
@@ -342,7 +346,7 @@
 #if DEBUG>2  
   _nss_pgsql_log(LOG_DEBUG,"getpwname(%s) return [%d]",name,status);
 #endif
-  __libc_lock_unlock (_nss_pg_lock);
+  pthread_mutex_unlock(&lock);
   return status;
 }
 
@@ -352,7 +356,8 @@
   char uidstr[21];	/* We will probably never have a gid_t with more than 64 bit. */
 
   snprintf (uidstr, sizeof uidstr, "%d", uid);
-  __libc_lock_lock (_nss_pg_lock);
+  if (pthread_mutex_lock(&lock))
+     return NSS_STATUS_TRYAGAIN;
   status = internal_setpwent ();
   if (status == NSS_STATUS_SUCCESS) {
 		status = lookup (uidstr, "uid", pwd, buffer, buflen, errnop);
@@ -361,7 +366,7 @@
 #if DEBUG>2  
   _nss_pgsql_log(LOG_DEBUG,"getpwuid(%d) return [%d]",uid,status);
 #endif  
-  __libc_lock_unlock (_nss_pg_lock);
+  pthread_mutex_unlock(&lock);
   return status;
 }
 
@@ -370,9 +375,10 @@
 {
 	enum nss_status status;
 
-	__libc_lock_lock (_nss_pg_lock);
+    if (pthread_mutex_lock(&lock))
+      return NSS_STATUS_TRYAGAIN;
 	status = lookup (NULL, "ent", pwd, buffer, buflen, errnop);
-	__libc_lock_unlock (_nss_pg_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }
 
Index: shadow.c
===================================================================
--- shadow.c
+++ shadow.c	2012-08-13 22:23:06.978765788 +0200
@@ -12,9 +12,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include "nss_setup.h"
+#include <pthread.h>
 
 /* Locks the static variables in this file.  */
-static pthread_mutex_t _nss_pg_sp_lock;
+static pthread_mutex_t lock;
 
 /* global var : the connection handler */
 static PGconn *pgconn_spwd = NULL;
@@ -266,21 +267,23 @@
 {
 	enum nss_status status;
 
-	__libc_lock_lock (_nss_pg_sp_lock);
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
 	status = internal_setspent ();
 	if (status == NSS_STATUS_SUCCESS ) { 
 	   status = cursor_begin();
 	}
-	__libc_lock_unlock (_nss_pg_sp_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }
 
 enum nss_status _nss_pgsql_endspent (void)
 {
-	__libc_lock_lock (_nss_pg_sp_lock);
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
 	cursor_close();
 	internal_endspent ();
-	__libc_lock_unlock (_nss_pg_sp_lock);
+    pthread_mutex_unlock(&lock);
 	return NSS_STATUS_SUCCESS;
 }
 
@@ -289,8 +292,9 @@
 {
 	enum nss_status status;
 
-	__libc_lock_lock (_nss_pg_sp_lock);
-	status = internal_setspent();
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
+    status = internal_setspent();
 	if ( status == NSS_STATUS_SUCCESS ) { 
 	   status = lookup (name, "nam", sp, buffer, buflen, errnop);
 	   internal_endspent();
@@ -298,7 +302,7 @@
 #if DEBUG>2	
    _nss_pgsql_log(LOG_ERR,"getspnam(%s) return %d",name,status);
 #endif   
-	__libc_lock_unlock (_nss_pg_sp_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }
 
@@ -307,9 +311,10 @@
 {
 	enum nss_status status;
 
-	__libc_lock_lock (_nss_pg_sp_lock);
+    if (pthread_mutex_lock(&lock))
+        return NSS_STATUS_TRYAGAIN;
 	status = lookup (NULL, "ent", sp, buffer, buflen, errnop);
-	__libc_lock_unlock (_nss_pg_sp_lock);
+    pthread_mutex_unlock(&lock);
 	return status;
 }