[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#5808) jldap library connect timeout doesn't work



Full_Name: Matt Stevenson
Version: 
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (62.129.121.62)


I believe trying to timeout using "LDAPConnection(int timeout)" will not work.
The below patch fixes that, with limited testing.

Regards
Matt

I, Matt Stevenson, hereby place the following modifications to OpenLDAP Software
(and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose with or
without attribution and/or other notice.

### Eclipse Workspace Patch 1.0
#P jldap
Index: com/novell/ldap/Connection.java
===================================================================
RCS file: /repo/OpenLDAP/pkg/jldap/com/novell/ldap/Connection.java,v
retrieving revision 1.91
diff -u -r1.91 Connection.java
--- com/novell/ldap/Connection.java	22 Feb 2008 11:29:50 -0000	1.91
+++ com/novell/ldap/Connection.java	13 Nov 2008 11:22:30 -0000
@@ -21,7 +21,7 @@
 import java.net.Socket;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
-
+import java.net.InetSocketAddress;
 
 import com.novell.ldap.asn1.*;
 import com.novell.ldap.client.*;
@@ -454,7 +454,10 @@
                     }
                     socket = mySocketFactory.createSocket(host, port);
                 } else {
-                	socket = new Socket(host, port);
+                	socket = new Socket();
+                	InetSocketAddress socketAddress = new InetSocketAddress(host,
port);
+                	socket.connect(socketAddress, myTimeOut);
+                	//socket = new Socket(host, port);
                 	if(myTimeOut > 0)
                 	{
                 		socket.setSoTimeout(myTimeOut);