From 57a1a2d18386d01af5a3f6d72e63afe2b2954c71 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 31 Aug 2006 20:31:43 +0000
Subject: [PATCH] Update a number of the client-side tools provided with OpenDS to ensure that they use consistently incrementing message IDs for requests sent to the server. In at least one case, it was possible for the same message ID to be used by the client for two consecutive requests, which could trigger a race condition that caused the server to refuse the second request.

---
 opends/src/server/org/opends/server/tools/StopDS.java |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/StopDS.java b/opends/src/server/org/opends/server/tools/StopDS.java
index c28a1b0..b474664 100644
--- a/opends/src/server/org/opends/server/tools/StopDS.java
+++ b/opends/src/server/org/opends/server/tools/StopDS.java
@@ -35,6 +35,7 @@
 import java.util.LinkedList;
 import java.util.TimeZone;
 import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.opends.server.controls.ProxiedAuthV2Control;
 import org.opends.server.protocols.asn1.ASN1Element;
@@ -461,12 +462,14 @@
 
 
     // Attempt to connect and authenticate to the Directory Server.
+    AtomicInteger nextMessageID = new AtomicInteger(1);
     LDAPConnection connection;
     try
     {
       connection = new LDAPConnection(host.getValue(), port.getIntValue(),
                                       connectionOptions);
-      connection.connectToHost(bindDN.getValue(), bindPW.getValue());
+      connection.connectToHost(bindDN.getValue(), bindPW.getValue(),
+                               nextMessageID);
     }
     catch (ArgumentException ae)
     {
@@ -549,7 +552,8 @@
 
     AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN,
                                                                attributes);
-    LDAPMessage requestMessage = new LDAPMessage(1, addRequest, controls);
+    LDAPMessage requestMessage =
+         new LDAPMessage(nextMessageID.getAndIncrement(), addRequest, controls);
 
 
     // Send the request to the server and read the response.

--
Gitblit v1.10.0