You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Burroughs <ch...@gmail.com> on 2011/09/02 03:37:17 UTC

tomcat-6 socket.soLingerOn vs connectionLinger

Looking at the Connector configuration options I'm having trouble
reconciling the description of socket.soLingerOn and connectionLinger [1]

connectionLinger: The number of milliseconds during which the sockets
used by this Connector will linger when they are closed. The default
value is -1 (socket linger is disabled).

socket.soLingerOn=(bool)Boolean value for the sockets so linger option
(SO_LINGER). Default value is true. This option is paired with the
soLingerTime value.

So it sounds like connectionLinger is just a way of setting
socket.soLingerOn, but then it would be redundant to have two options.
Are they about different sockets?  The defaults are also opposites.  If
both options affect SO_LINGER time, which takes precedence?

Also, the units of connectionLinger are milliseconds, but
java.net.Socket#setSoLinger uses seconds, so I'm not sure how greater
than second precision could be achieved.

[1] http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat-6 socket.soLingerOn vs connectionLinger

Posted by Mark Thomas <ma...@apache.org>.
On 02/09/2011 02:37, Chris Burroughs wrote:
> Looking at the Connector configuration options I'm having trouble
> reconciling the description of socket.soLingerOn and connectionLinger [1]

The documentation is a bit of a mess here. I'll explain what should
happen below and try and clean up the documentation.

There are three (or four) attributes to consider:
connectionLinger (a.k.a. soLinger)
socket.soLingerOn
socket.soLingerTime

The simplest way to understand how they interact is to look at the
setSoLingermethod in the endpoint

public void setSoLinger(int soLinger) {
    socketProperties.setSoLingerTime(soLinger);
    socketProperties.setSoLingerOn(soLinger>=0);
}

connectionLinger is essentially a short-cut to setting soLingerTime and
soLingerOn

> So it sounds like connectionLinger is just a way of setting
> socket.soLingerOn, but then it would be redundant to have two options.

Yes, it is redundant. connectionLinger was first and then when the
socket.* attributes were added, all the socket attributes were exposed
creating the redundancy.

> Are they about different sockets?
No.

> The defaults are also opposites.  If
> both options affect SO_LINGER time, which takes precedence?

trunk and Tomcat 7: JVM defaults are used. If both are set in server.xml
(don't do that) it depends on the order in which the attributes are read.

Tomcat 6:
 BIO & APR. Only support connectionLinger. Default 100.
 NIO. Supports all three (four). Default 25.

> Also, the units of connectionLinger are milliseconds, but
> java.net.Socket#setSoLinger uses seconds, so I'm not sure how greater
> than second precision could be achieved.

It can't. The units of connectionLinger are seconds. That is another
documentation error.

The docs have been fixed for trunk, 7.0.x and 6.0.x and will be included
in 7.0.22 & 6.0.34 onwards.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org