r7148: Fix #2736: winbind race condition with detecting idle clients
authorJim McDonough <jmcd@samba.org>
Tue, 31 May 2005 18:36:38 +0000 (18:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:57:03 +0000 (10:57 -0500)
winbind idle connection closing logic is getting invoked under high loads for
clients which may already have commands in the pipe.  This race condition
causes clients to fail with NSS_STATUS_UNAVAIL sometimes.  We now retry several
times hoping (still not guaranteed, though) it will work.
(This used to be commit 05c04cfd2526b8b9a82916b5dffc18bf27c3f198)

source3/nsswitch/wb_common.c

index 40cf534c41d9d2eb7cc472c85ecadcfc0d893e6d..d2e8b9cc6ace4ef80da8b9798877e7b7db66af6a 100644 (file)
@@ -588,12 +588,18 @@ NSS_STATUS winbindd_request(int req_type,
                            struct winbindd_request *request,
                            struct winbindd_response *response)
 {
-       NSS_STATUS status;
+       NSS_STATUS status = NSS_STATUS_UNAVAIL;
+       int count = 0;
 
-       status = winbindd_send_request(req_type, request);
-       if (status != NSS_STATUS_SUCCESS) 
-               return(status);
-       return winbindd_get_response(response);
+       while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
+               status = winbindd_send_request(req_type, request);
+               if (status != NSS_STATUS_SUCCESS) 
+                       return(status);
+               status = winbindd_get_response(response);
+               count += 1;
+       }
+
+       return status;
 }
 
 /*************************************************************************
@@ -606,7 +612,7 @@ NSS_STATUS winbindd_request(int req_type,
 
 BOOL winbind_off( void )
 {
-        static char *s = CONST_DISCARD(char *, WINBINDD_DONT_ENV "=1");
+       static char *s = CONST_DISCARD(char *, WINBINDD_DONT_ENV "=1");
 
        return putenv(s) != -1;
 }