From fcf635c6a4436df96ac25e50f76d7e2c78e971b9 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 03 Sep 2007 19:53:23 +0000
Subject: [PATCH] Implement support for a maximum blocked write time limit in the LDAP connection handler, which can be used to terminate client connections if an attempt to write data to the client has been blocked for too long. This will generally occur if the client has become unresponsive or there is a network outage.
---
opends/src/server/org/opends/server/api/ClientConnection.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/opends/src/server/org/opends/server/api/ClientConnection.java b/opends/src/server/org/opends/server/api/ClientConnection.java
index a001892..64500af 100644
--- a/opends/src/server/org/opends/server/api/ClientConnection.java
+++ b/opends/src/server/org/opends/server/api/ClientConnection.java
@@ -25,24 +25,26 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.api;
-import org.opends.messages.Message;
import java.net.InetAddress;
import java.nio.ByteBuffer;
+import java.nio.channels.Selector;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.opends.messages.Message;
import org.opends.server.api.plugin.IntermediateResponsePluginResult;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PersistentSearch;
import org.opends.server.core.PluginConfigManager;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.NetworkGroup;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.AbstractOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
@@ -62,11 +64,9 @@
import org.opends.server.types.SearchResultReference;
import org.opends.server.util.TimeThread;
+import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.messages.CoreMessages.*;
-
import static org.opends.server.util.StaticUtils.*;
@@ -402,6 +402,49 @@
/**
+ * Retrieves a {@code Selector} that may be used to ensure that
+ * write operations complete in a timely manner, or terminate the
+ * connection in the event that they fail to do so. This is an
+ * optional method for client connections, and the default
+ * implementation returns {@code null} to indicate that the maximum
+ * blocked write time limit is not supported for this connection.
+ * Subclasses that do wish to support this functionality should
+ * return a valid {@code Selector} object.
+ *
+ * @return The {@code Selector} that may be used to ensure that
+ * write operations complete in a timely manner, or
+ * {@code null} if this client connection does not support
+ * maximum blocked write time limit functionality.
+ */
+ public Selector getWriteSelector()
+ {
+ // There will not be a write selector in the default
+ // implementation.
+ return null;
+ }
+
+
+
+ /**
+ * Retrieves the maximum length of time in milliseconds that
+ * attempts to write data to the client should be allowed to block.
+ * A value of zero indicates there should be no limit.
+ *
+ * @return The maximum length of time in milliseconds that attempts
+ * to write data to the client should be allowed to block,
+ * or zero if there should be no limit.
+ */
+ public long getMaxBlockedWriteTimeLimit()
+ {
+ // By default, we'll return 0, which indicates that there should
+ // be no maximum time limit. Subclasses should override this if
+ // they want to support a maximum blocked write time limit.
+ return 0L;
+ }
+
+
+
+ /**
* Indicates that the data in the provided buffer has been read from
* the client and should be processed. The contents of the provided
* buffer will be in clear-text (the data may have been passed
--
Gitblit v1.10.0