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

gbellato
11.18.2009 aa62a3550f96cac31d081254169939a46c9a387d
While investigating issue 4046 I've noticed that in case of an error during the
SSL handshake that is used for the authentication of the replication session
the associated socket is not correctly closed by the replication code.
The socket therefore is left open and the associated resources are never free.

This change fix this problem.
It will not solve the root cause of the 4046 issue but will help to keep the server
running by avoiding to consume of the process resources.

The issue 3713 might also be related to this problem because the symptoms are
similar.
2 files modified
28 ■■■■■ changed files
opends/src/server/org/opends/server/controls/ExternalChangelogRequestControl.java 10 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServer.java 18 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/controls/ExternalChangelogRequestControl.java
@@ -29,12 +29,10 @@
import static org.opends.server.protocols.asn1.ASN1Constants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.getExceptionMessage;
import static org.opends.server.loggers.debug.DebugLogger.getTracer;
import java.io.IOException;
import org.opends.messages.Message;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1;
import org.opends.server.protocols.asn1.ASN1Reader;
import org.opends.server.protocols.asn1.ASN1Writer;
@@ -48,19 +46,15 @@
/**
 * This class implements the persistent search control defined in
 * draft-ietf-ldapext-psearch.  It makes it possible for clients to be notified
 * of changes to information in the Directory Server as they occur.
 * This class implements the control used to browse the external changelog.
 */
public class ExternalChangelogRequestControl
       extends Control
{
  private static final DebugTracer TRACER = getTracer();
  private MultiDomainServerState cookie;
  /**
   * ControlDecoder implentation to decode this control from a ByteString.
   * ControlDecoder implementation to decode this control from a ByteString.
   */
  private final static class Decoder
      implements ControlDecoder<ExternalChangelogRequestControl>
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -248,8 +248,6 @@
  void runListen()
  {
    Socket newSocket;
    // wait for the connect thread to find other replication
    // servers in the topology before starting to accept connections
    // from the ldap servers.
@@ -272,16 +270,30 @@
      // Read incoming messages and create LDAP or ReplicationServer listener
      // and Publisher.
      ProtocolSession session;
      Socket newSocket = null;
      try
      {
      try
      {
        newSocket =  listenSocket.accept();
        newSocket.setTcpNoDelay(true);
        newSocket.setKeepAlive(true);
        ProtocolSession session =
          session =
             replSessionSecurity.createServerSession(newSocket,
             ReplSessionSecurity.HANDSHAKE_TIMEOUT);
        if (session == null) // Error, go back to accept
          continue;
        }
        catch (Exception e)
        {
          // If problems happen during the SSL handshake, it is necessary
          // to close the socket to free the associated resources.
          if (newSocket != null)
            newSocket.close();
          continue;
        }
        ReplicationMsg msg = session.receive();