svn commit: samba r18010 - in branches/SAMBA_3_0/source: libads nsswitch

jra at samba.org jra at samba.org
Sat Sep 2 23:06:22 GMT 2006


Author: jra
Date: 2006-09-02 23:06:21 +0000 (Sat, 02 Sep 2006)
New Revision: 18010

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18010

Log:
Ensure we don't timeout twice to the same
server in winbindd when it's down and listed
in the -ve connection cache. Fix memory leak,
reduce timeout for cldap calls - minimum 3 secs.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/libads/cldap.c
   branches/SAMBA_3_0/source/libads/kerberos.c
   branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c


Changeset:
Modified: branches/SAMBA_3_0/source/libads/cldap.c
===================================================================
--- branches/SAMBA_3_0/source/libads/cldap.c	2006-09-02 21:47:56 UTC (rev 18009)
+++ branches/SAMBA_3_0/source/libads/cldap.c	2006-09-02 23:06:21 UTC (rev 18010)
@@ -188,6 +188,8 @@
 	DATA_BLOB blob;
 	DATA_BLOB os1, os2, os3;
 	int i1;
+	/* half the time of a regular ldap timeout, not less than 3 seconds. */
+	unsigned int al_secs = MAX(3,lp_ldap_timeout()/2);
 	char *p;
 
 	blob = data_blob(NULL, 8192);
@@ -200,7 +202,7 @@
 	/* Setup timeout */
 	gotalarm = 0;
 	CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
-	alarm(lp_ldap_timeout());
+	alarm(al_secs);
 	/* End setup timeout. */
  
 	ret = read(sock, blob.data, blob.length);

Modified: branches/SAMBA_3_0/source/libads/kerberos.c
===================================================================
--- branches/SAMBA_3_0/source/libads/kerberos.c	2006-09-02 21:47:56 UTC (rev 18009)
+++ branches/SAMBA_3_0/source/libads/kerberos.c	2006-09-02 23:06:21 UTC (rev 18010)
@@ -494,10 +494,13 @@
 		kdc_str = talloc_asprintf(mem_ctx, "%s\tkdc = %s\n",
 			kdc_str, inet_ntoa(ip_srv[i].ip));
 		if (!kdc_str) {
+			SAFE_FREE(ip_srv);
 			return NULL;
 		}
 	}
 
+	SAFE_FREE(ip_srv);
+
 	DEBUG(10,("get_kdc_ip_string: Returning %s\n",
 		kdc_str ));
 

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c	2006-09-02 21:47:56 UTC (rev 18009)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c	2006-09-02 23:06:21 UTC (rev 18010)
@@ -791,17 +791,22 @@
 	char *saf_servername = saf_fetch( domain->name );
 	int retries;
 
-	if ((mem_ctx = talloc_init("cm_open_connection")) == NULL)
+	if ((mem_ctx = talloc_init("cm_open_connection")) == NULL) {
+		SAFE_FREE(saf_servername);
 		return NT_STATUS_NO_MEMORY;
+	}
 
 	/* we have to check the server affinity cache here since 
 	   later we selecte a DC based on response time and not preference */
 	   
-	if ( saf_servername ) 
-	{
+	/* Check the negative connection cache
+	   before talking to it. It going down may have
+	   triggered the reconnection. */
+
+	if ( saf_servername && NT_STATUS_IS_OK(check_negative_conn_cache( domain->name, saf_servername))) {
+
 		/* convert an ip address to a name */
-		if ( is_ipaddress( saf_servername ) )
-		{
+		if ( is_ipaddress( saf_servername ) ) {
 			fstring saf_name;
 			struct in_addr ip;
 
@@ -814,9 +819,7 @@
 					domain->name, saf_servername,
 					NT_STATUS_UNSUCCESSFUL);
 			}
-		} 
-		else 
-		{
+		} else {
 			fstrcpy( domain->dcname, saf_servername );
 		}
 



More information about the samba-cvs mailing list