mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ludovicp
07.12.2010 065c1ae206bec7f9dcdd394f5fe06ab8e4005655
Fix issue #2748. This patch changes the place where messages are logged to ensure correct ordering: - Request handler now logs the connect messages before registering the read interest. - Worker threads logs the response messages before sending it to the client.
11 files modified
82 ■■■■ changed files
opends/src/server/org/opends/server/core/AddOperationBasis.java 6 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/BindOperationBasis.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/CompareOperationBasis.java 9 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DeleteOperationBasis.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ExtendedOperationBasis.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ModifyOperationBasis.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/SearchOperationBasis.java 17 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java 4 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java 2 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/AddOperationBasis.java
@@ -782,6 +782,9 @@
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logAddResponse(this);
      if(cancelRequest == null || cancelResult == null ||
          cancelResult.getResultCode() != ResultCode.CANCELED ||
          cancelRequest.notifyOriginalRequestor() ||
@@ -791,9 +794,6 @@
      }
      // Log the add response message.
      logAddResponse(this);
      // Invoke the post-response callbacks.
      if (workflowExecuted) {
        invokePostResponseCallbacks();
opends/src/server/org/opends/server/core/BindOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2007-2009 Sun Microsystems, Inc.
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 */
package org.opends.server.core;
import org.opends.messages.Message;
@@ -836,6 +836,9 @@
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the bind response.
      logBindResponse(this);
      // Send the bind response to the client.
      clientConnection.sendResponse(this);
@@ -848,9 +851,6 @@
      clientConnection.finishBindOrStartTLS();
      // Log the bind response.
      logBindResponse(this);
      // Invoke the post-response bind plugins.
      invokePostResponsePlugins(workflowExecuted);
    }
opends/src/server/org/opends/server/core/CompareOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2007-2009 Sun Microsystems, Inc.
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 */
package org.opends.server.core;
import org.opends.messages.MessageBuilder;
@@ -587,6 +587,9 @@
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the compare response message.
      logCompareResponse(this);
      if(cancelRequest == null || cancelResult == null ||
          cancelResult.getResultCode() != ResultCode.CANCELED ||
          cancelRequest.notifyOriginalRequestor() ||
@@ -595,10 +598,6 @@
        clientConnection.sendResponse(this);
      }
      // Log the compare response message.
      logCompareResponse(this);
      // Invoke the post-response compare plugins.
      invokePostResponsePlugins(workflowExecuted);
opends/src/server/org/opends/server/core/DeleteOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 */
package org.opends.server.core;
import org.opends.messages.MessageBuilder;
@@ -435,6 +435,9 @@
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the delete response.
      logDeleteResponse(this);
      if(cancelRequest == null || cancelResult == null ||
          cancelResult.getResultCode() != ResultCode.CANCELED ||
          cancelRequest.notifyOriginalRequestor() ||
@@ -444,9 +447,6 @@
      }
      // Log the delete response.
      logDeleteResponse(this);
      // Invoke the post-response callbacks.
      if (workflowExecuted) {
        invokePostResponseCallbacks();
opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.core;
import org.opends.messages.MessageBuilder;
@@ -520,6 +520,9 @@
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the extended response.
      logExtendedResponse(this);
      // Send the response to the client.
      if(cancelRequest == null || cancelResult == null ||
          cancelResult.getResultCode() != ResultCode.CANCELED ||
@@ -534,9 +537,6 @@
        clientConnection.finishBindOrStartTLS();
      }
      // Log the extended response.
      logExtendedResponse(this);
      // Invoke the post-response extended plugins.
      pluginConfigManager.invokePostResponseExtendedPlugins(this);
opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.core;
import org.opends.messages.MessageBuilder;
@@ -651,6 +651,9 @@
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the modify DN response.
      logModifyDNResponse(this);
      if(cancelRequest == null || cancelResult == null ||
          cancelResult.getResultCode() != ResultCode.CANCELED ||
          cancelRequest.notifyOriginalRequestor() ||
@@ -659,9 +662,6 @@
        clientConnection.sendResponse(this);
      }
      // Log the modify DN response.
      logModifyDNResponse(this);
      // Invoke the post-response callbacks.
      if (workflowExecuted) {
        invokePostResponseCallbacks();
opends/src/server/org/opends/server/core/ModifyOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2007-2009 Sun Microsystems, Inc.
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 */
package org.opends.server.core;
@@ -536,6 +536,9 @@
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the modify response.
      logModifyResponse(this);
      if(cancelRequest == null || cancelResult == null ||
          cancelResult.getResultCode() != ResultCode.CANCELED ||
          cancelRequest.notifyOriginalRequestor() ||
@@ -544,9 +547,6 @@
        clientConnection.sendResponse(this);
      }
      // Log the modify response.
      logModifyResponse(this);
      // Invoke the post-response callbacks.
      if (workflowExecuted) {
        invokePostResponseCallbacks();
opends/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.core;
@@ -811,11 +811,12 @@
    // Send the entry to the client.
    if (pluginResult.sendResponse())
    {
      // Log the entry sent to the client.
      logSearchResultEntry(this, searchEntry);
      try
      {
        sendSearchEntry(searchEntry);
        // Log the entry sent to the client.
        logSearchResultEntry(this, searchEntry);
        incrementEntriesSent();
      }
@@ -889,12 +890,13 @@
    // to send any more.
    if (pluginResult.sendResponse())
    {
      // Log the entry sent to the client.
      logSearchResultReference(this, reference);
      try
      {
        if (sendSearchReference(reference))
        {
          // Log the entry sent to the client.
          logSearchResultReference(this, reference);
          incrementReferencesSent();
          // FIXME -- Should the size limit apply here?
@@ -931,12 +933,11 @@
    // multithreaded in the event of a persistent search, so do it safely.
    if (responseSent.compareAndSet(false, true))
    {
      // Send the response to the client.
      clientConnection.sendResponse(this);
      // Log the search result.
      logSearchResultDone(this);
      // Send the response to the client.
      clientConnection.sendResponse(this);
      // Invoke the post-response search plugins.
      invokePostResponsePlugins();
opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
@@ -1418,7 +1418,7 @@
      return;
    }
    StringBuilder buffer = new StringBuilder(100);
    StringBuilder buffer = new StringBuilder(192);
    appendHeader(searchOperation, "SEARCH", CATEGORY_REQUEST, buffer);
    buffer.append(" base=\"");
    buffer.append(searchOperation.getRawBaseDN().toString());
@@ -1470,7 +1470,7 @@
      return;
    }
    StringBuilder buffer = new StringBuilder(100);
    StringBuilder buffer = new StringBuilder(128);
    appendHeader(searchOperation, "SEARCH", CATEGORY_RESPONSE, buffer);
    buffer.append(" result=");
    buffer.append(searchOperation.getResultCode().getIntValue());
opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
@@ -22,11 +22,10 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.protocols.ldap;
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.ServerConstants.*;
@@ -1156,7 +1155,6 @@
      if (requestHandler
          .registerClient(clientConnection)) {
        logConnect(clientConnection);
      }
    } catch (Exception e) {
      if (debugEnabled())
opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java
@@ -29,6 +29,7 @@
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.server.loggers.AccessLogger.logConnect;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.StaticUtils.*;
@@ -265,6 +266,7 @@
            SocketChannel socketChannel = c.getSocketChannel();
            socketChannel.configureBlocking(false);
            socketChannel.register(selector, SelectionKey.OP_READ, c);
            logConnect(c);
          }
          catch (Exception e)
          {