Rev 614: merge from volker and ronnie in http://samba.org/~tridge/3_0-ctdb

tridge at samba.org tridge at samba.org
Wed Sep 5 02:02:47 GMT 2007


------------------------------------------------------------
revno: 614
revision-id: tridge at samba.org-20070905020246-yy3om8ebmwrhumf6
parent: tridge at samba.org-20070831042358-on8mb4xazegvdpzg
parent: vl at samba.org-20070903102857-wtpdxiamlin2zcb6
committer: Andrew Tridgell <tridge at samba.org>
branch nick: s3-ctdb-tridge
timestamp: Wed 2007-09-05 12:02:46 +1000
message:
  merge from volker and ronnie
modified:
  source/nsswitch/wb_common.c    wb_common.c-20070210173807-1wjifrbwaz6xnmgl-719
    ------------------------------------------------------------
    revno: 609.1.2
    revision-id: vl at samba.org-20070903102857-wtpdxiamlin2zcb6
    parent: vl at samba.org-20070830123350-suiuveayvu3jifn1
    committer: Volker Lendecke <vl at samba.org>
    branch nick: samba_3_0_ctdb
    timestamp: Mon 2007-09-03 12:28:57 +0200
    message:
      Based on a patch by Ronnie, improve wb_common.c:
      
      Handling of retries in case winbind kills that client is corrected
      
      wb_common.c caches the information about the winbind privileged pipe directory.
      This means that in the child smbd less round-trips to winbind are necessary in
      case of a reconnect storm
    modified:
      source/nsswitch/wb_common.c    wb_common.c-20070210173807-1wjifrbwaz6xnmgl-719
=== modified file 'source/nsswitch/wb_common.c'
--- a/source/nsswitch/wb_common.c	2007-03-22 23:31:57 +0000
+++ b/source/nsswitch/wb_common.c	2007-09-03 10:28:57 +0000
@@ -34,6 +34,7 @@
 
 int winbindd_fd = -1;           /* fd for winbindd socket */
 static int is_privileged = 0;
+static char *priv_directory;
 
 /* Free a response structure */
 
@@ -314,6 +315,19 @@
 		return -1;
 	}
 
+	if (priv_directory != NULL) {
+		winbindd_fd = winbind_named_pipe_sock(priv_directory);
+		if (winbindd_fd != -1) {
+			is_privileged = 1;
+			return winbindd_fd;
+		}
+
+		/*
+		 * Maybe winbind has changed
+		 */
+		SAFE_FREE(priv_directory);
+	}
+
 	if ((winbindd_fd = winbind_named_pipe_sock(WINBINDD_SOCKET_DIR)) == -1) {
 		return -1;
 	}
@@ -328,6 +342,10 @@
 		return -1;
 	}
 
+	if (need_priv == 0) {
+		return winbindd_fd;
+	}
+
 	/* try and get priv pipe */
 
 	request.flags = WBFLAG_RECURSE;
@@ -337,6 +355,8 @@
 			close(winbindd_fd);
 			winbindd_fd = fd;
 			is_privileged = 1;
+			priv_directory = strdup(
+				(char *)response.extra_data.data);
 		}
 	}
 
@@ -626,6 +646,23 @@
 
 	while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
 		status = winbindd_send_request(req_type, 0, request);
+		if (status == NSS_STATUS_UNAVAIL) {
+			if ((request != NULL)
+			    && (request->flags & WBFLAG_RECURSE)) {
+				return status;
+			}
+			/*
+			 * Something might have failed in the previous
+			 * iteration which caused the filehandle to be closed
+			 * so we sleep for 1 second and try reopening the
+			 * filehandle
+			 */
+			close_sock();
+			sleep(1);
+			winbindd_fd = winbind_open_pipe_sock(0, 0);
+			count++;
+			continue;
+		}
 		if (status != NSS_STATUS_SUCCESS) 
 			return(status);
 		status = winbindd_get_response(response);
@@ -644,6 +681,23 @@
 
 	while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
 		status = winbindd_send_request(req_type, 1, request);
+		if (status == NSS_STATUS_UNAVAIL) {
+			if ((request != NULL)
+			    && (request->flags & WBFLAG_RECURSE)) {
+				return status;
+			}
+			/*
+			 * Something might have failed in the previous
+			 * iteration which caused the filehandle to be closed
+			 * so we sleep for 1 second and try reopening the
+			 * filehandle
+			 */
+			close_sock();
+			sleep(1);
+			winbindd_fd = winbind_open_pipe_sock(0, 1);
+			count++;
+			continue;
+		}
 		if (status != NSS_STATUS_SUCCESS) 
 			return(status);
 		status = winbindd_get_response(response);



More information about the samba-cvs mailing list