From 32d694939d9deac5b4ef008855c2fe1dc97513a3 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Tue, 03 Aug 2010 16:19:34 +0000
Subject: [PATCH] Revert commit 6559 and complete commit 6550. There were some inconsistencies in the way the connectTimeout was applied to the tools. The time out should only apply to the establishing of the connection not to every operation done in the connection. But due to a defect, the timeout was kept for all subsequent operations preventing some of them to complete. The proposed changes reset the timeout of the socket to 0 (no timeout) once the connection has been established. Default connection timeout has been reset to 30 seconds for all tools.

---
 opends/src/server/org/opends/server/tools/LDAPConnection.java |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/LDAPConnection.java b/opends/src/server/org/opends/server/tools/LDAPConnection.java
index 5703deb..8a2729b 100644
--- a/opends/src/server/org/opends/server/tools/LDAPConnection.java
+++ b/opends/src/server/org/opends/server/tools/LDAPConnection.java
@@ -31,6 +31,7 @@
 import java.io.IOException;
 import java.net.ConnectException;
 import java.net.Socket;
+import java.net.SocketException;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -82,8 +83,8 @@
   private LDAPReader ldapReader;
   private int versionNumber = 3;
 
-  private PrintStream out;
-  private PrintStream err;
+  private final PrintStream out;
+  private final PrintStream err;
 
   /**
    * Constructor for the LDAPConnection object.
@@ -509,6 +510,24 @@
       throw new LDAPConnectionException(
               Message.raw(ex.getLocalizedMessage()),ex);
     }
+    finally
+    {
+      if (timeout > 0)
+      {
+        try
+        {
+          socket.setSoTimeout(0);
+        }
+        catch (SocketException e)
+        {
+          e.printStackTrace();
+          if (debugEnabled())
+          {
+            TRACER.debugCaught(DebugLogLevel.ERROR, e);
+          }
+        }
+      }
+    }
 
   }
 

--
Gitblit v1.10.0