[ 
https://issues.apache.org/jira/browse/DIRSERVER-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12494802
 ] 

Mark Swanson commented on DIRSERVER-926:
----------------------------------------

The problem must be that cfg.isReuseAddress() == false

In Mina 1.0.0: 
core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
About line 426:

                // Configure the server socket,
                SocketAcceptorConfig cfg;
                if( req.config instanceof SocketAcceptorConfig )
                {
                    cfg = ( SocketAcceptorConfig ) req.config;
                }
                else
                {
                    cfg = ( SocketAcceptorConfig ) getDefaultConfig();
                }

                ssc.socket().setReuseAddress( cfg.isReuseAddress() );
                ssc.socket().setReceiveBufferSize(
                    ( ( SocketSessionConfig ) cfg.getSessionConfig() 
).getReceiveBufferSize() );

                // and bind.
                ssc.socket().bind( req.address, cfg.getBacklog() );

Maybe as a quick check we could walk backwards from this point and figure out 
why this is false.
Ok, I ran this through the debugger and isReuseAddress() == true. 
The only possibilities I see are:
1. setReceiveBufferSize() is changing reuseAddress. unlikely
2. Java 6 bind() ignores  reuseAddress. unlikely

The Java 6 changelog doesn't give any indication, and I couldn't find any help 
from Google.
I'm out.

Cheers.




> Can not restart ADS because SO_REUSEADDR isn't used.
> ----------------------------------------------------
>
>                 Key: DIRSERVER-926
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-926
>             Project: Directory ApacheDS
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>         Environment: Java 6 build 105, Linux CentOS 4.4.
>            Reporter: Mark Swanson
>
> Shutting down ADS leaves all existing connections in FIN_WAIT1. This isn't a 
> problem.
> However, when starting up ADS again any previous connection still in 
> FIN_WAIT1 will prevent ADS from starting.
> The only workaround is to wait until all FIN_WAIT1 connections timeout and 
> get closed by the OS.
> On the mailing list Emmanuel already checked this:
> This is already done :
> ...
>        try
>        {
>            // Disable the disconnection of the clients on unbind
>            SocketAcceptorConfig acceptorCfg = new SocketAcceptorConfig();
>            acceptorCfg.setDisconnectOnUnbind( false );
>            acceptorCfg.setReuseAddress( true );
> ... 
> The 100% reproducible stack trace when existing FIN_WAIT1 connections are 
> present:
> [00:38:48] ERROR [org.apache.directory.daemon.Bootstrapper] - Failed on 
> org.apache.directory.server.Service.init(InstallationLayout, String[])
> org.apache.directory.shared.ldap.exception.LdapConfigurationException: Failed 
> to bind an LDAPservice (389) to the service registry. [Root exception is 
> java.net.BindException: Address already in use]
>     at 
> org.apache.directory.server.jndi.ServerContextFactory.startLDAP0(ServerContextFactory.java:487)
>     at 
> org.apache.directory.server.jndi.ServerContextFactory.startLDAP(ServerContextFactory.java:401)
>     at 
> org.apache.directory.server.jndi.ServerContextFactory.afterStartup(ServerContextFactory.java:211)
>     at 
> org.apache.directory.server.core.DefaultDirectoryService.startup(DefaultDirectoryService.java:239)
>     at 
> org.apache.directory.server.core.jndi.AbstractContextFactory.getInitialContext(AbstractContextFactory.java:118)
>     at 
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
>     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>     at javax.naming.InitialContext.init(InitialContext.java:223)
>     at javax.naming.InitialContext.<init>(InitialContext.java:197)
>     at 
> javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:82)
>     at org.apache.directory.server.Service.init(Service.java:96)
>     at 
> org.apache.directory.daemon.Bootstrapper.callInit(Bootstrapper.java:151)
>     at 
> org.apache.directory.daemon.JsvcBootstrapper.init(JsvcBootstrapper.java:56)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at 
> org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:160)
> Caused by: java.net.BindException: Address already in use
>     at sun.nio.ch.Net.bind(Native Method)
>     at 
> sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
>     at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
>     at 
> org.apache.mina.transport.socket.nio.SocketAcceptor.registerNew(SocketAcceptor.java:429)
>     at 
> org.apache.mina.transport.socket.nio.SocketAcceptor.access$900(SocketAcceptor.java:52)
>     at 
> org.apache.mina.transport.socket.nio.SocketAcceptor$Worker.run(SocketAcceptor.java:258)
>     at 
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:43)
>     at java.lang.Thread.run(Thread.java:619)
> Once all of the existing connections leave FIN_WAIT1 this Exception does not 
> happen and the server starts normally.
> Cheers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to