From 282288d61ff6180e6798948e3aaa49271e306e70 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 30 Jul 2007 06:26:11 +0000
Subject: [PATCH] Update the server to provide an idle time limit configuration option that can be used to terminate client connections that have been idle for too long. This can be controlled on a server-wide default level using the ds-cfg-idle-time-limit configuration attribute in the cn=config entry, but it can also be overridden on a per-user level with the ds-rlim-idle-time-limit operational attribute in the user's entry.
---
opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
index 4cf5799..cbf90ee 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -89,6 +89,7 @@
import org.opends.server.types.ResultCode;
import org.opends.server.types.SearchResultEntry;
import org.opends.server.types.SearchResultReference;
+import org.opends.server.util.TimeThread;
@@ -108,6 +109,9 @@
+ // The time that the last operation was completed.
+ private AtomicLong lastCompletionTime;
+
// The next operation ID that should be used for this connection.
private AtomicLong nextOperationID;
@@ -240,6 +244,7 @@
ldapVersion = 3;
requestHandler = null;
+ lastCompletionTime = new AtomicLong(TimeThread.getTime());
nextOperationID = new AtomicLong(0);
connectionValid = true;
disconnectRequested = false;
@@ -1210,6 +1215,7 @@
}
operationsInProgress.remove(messageID);
+ lastCompletionTime.set(TimeThread.getTime());
throw de;
}
@@ -1247,7 +1253,15 @@
public boolean removeOperationInProgress(int messageID)
{
AbstractOperation operation = operationsInProgress.remove(messageID);
- return (operation != null);
+ if (operation == null)
+ {
+ return false;
+ }
+ else
+ {
+ lastCompletionTime.set(TimeThread.getTime());
+ return true;
+ }
}
@@ -1333,6 +1347,12 @@
}
}
+ if (! (operationsInProgress.isEmpty() &&
+ getPersistentSearches().isEmpty()))
+ {
+ lastCompletionTime.set(TimeThread.getTime());
+ }
+
operationsInProgress.clear();
@@ -1401,12 +1421,14 @@
}
operationsInProgress.remove(msgID);
+ lastCompletionTime.set(TimeThread.getTime());
}
for (PersistentSearch persistentSearch : getPersistentSearches())
{
DirectoryServer.deregisterPersistentSearch(persistentSearch);
+ lastCompletionTime.set(TimeThread.getTime());
}
}
catch (Exception e)
@@ -2789,5 +2811,32 @@
{
return connectionHandler.getSSLServerCertNickname();
}
+
+
+
+ /**
+ * Retrieves the length of time in milliseconds that this client
+ * connection has been idle.
+ * <BR><BR>
+ * Note that the default implementation will always return zero.
+ * Subclasses associated with connection handlers should override
+ * this method if they wish to provided idle time limit
+ * functionality.
+ *
+ * @return The length of time in milliseconds that this client
+ * connection has been idle.
+ */
+ public long getIdleTime()
+ {
+ if (operationsInProgress.isEmpty() && getPersistentSearches().isEmpty())
+ {
+ return (TimeThread.getTime() - lastCompletionTime.get());
+ }
+ else
+ {
+ // There's at least one operation in progress, so it's not idle.
+ return 0L;
+ }
+ }
}
--
Gitblit v1.10.0