[
https://issues.apache.org/jira/browse/DIRMINA-379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592132#action_12592132
]
Stefano Bagnara commented on DIRMINA-379:
-----------------------------------------
I checked out the latest 1.1 branch (1.1.8-SNAPSHOT).
The first time I ran the tests SocketBindTest failed with the usuale setInt
exception.
Then I've never been able to reproduce that failure in mina tests.
My application still show the issue so I changed the order of the
setReuseAddress and setKeepAlive, but my application still failed. So I also
added a check on the keepAlive to call the setter only when the value is really
changed and now I don't see the issue anymore.
Here is the patch I'm using:
Index:
mina-core-1.1/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionImpl.java
===================================================================
---
mina-core-1.1/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionImpl.java
(revision 651305)
+++
mina-core-1.1/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionImpl.java
(working copy)
@@ -98,10 +98,10 @@
IoSessionConfig sessionConfig = serviceConfig.getSessionConfig();
if (sessionConfig instanceof SocketSessionConfig) {
SocketSessionConfig cfg = (SocketSessionConfig) sessionConfig;
+ this.config.setReuseAddress(cfg.isReuseAddress());
this.config.setKeepAlive(cfg.isKeepAlive());
this.config.setOobInline(cfg.isOobInline());
this.config.setReceiveBufferSize(cfg.getReceiveBufferSize());
- this.config.setReuseAddress(cfg.isReuseAddress());
this.config.setSendBufferSize(cfg.getSendBufferSize());
this.config.setSoLinger(cfg.getSoLinger());
this.config.setTcpNoDelay(cfg.isTcpNoDelay());
@@ -229,7 +229,9 @@
public void setKeepAlive(boolean on) {
try {
- ch.socket().setKeepAlive(on);
+ if (ch.socket().getKeepAlive() != on) {
+ ch.socket().setKeepAlive(on);
+ }
} catch (SocketException e) {
throw new RuntimeIOException(e);
}
I'll do more tests as soon as I find the time for them.
> setKeepAlive/setTcpNoDelay and exceptions in Windows Vista
> ----------------------------------------------------------
>
> Key: DIRMINA-379
> URL: https://issues.apache.org/jira/browse/DIRMINA-379
> Project: MINA
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.0.3, 1.1.0, 2.0.0-M1
> Environment: Windows Vista Home Premium Italian
> Java SE 1.5.0_11, Java SE 1.6 Update 1, Java SE 1.4.2_12
> Reporter: Stefano Bagnara
> Assignee: Trustin Lee
>
> When I ran my application under Vista I get this exception:
> Exception in thread "Thread-4" org.apache.mina.common.RuntimeIOException:
> java.net.SocketException: Invalid argument: sun.nio.ch.Net.setIntOption
> at
> org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:252)
> at
> org.apache.mina.transport.socket.nio.SocketSessionImpl.<init>(SocketSessionImpl.java:94)
> at
> org.apache.mina.transport.socket.nio.SocketConnector.newSession(SocketConnector.java:350)
> at
> org.apache.mina.transport.socket.nio.SocketConnector.processSessions(SocketConnector.java:290)
> at
> org.apache.mina.transport.socket.nio.SocketConnector.access$900(SocketConnector.java:53)
> at
> org.apache.mina.transport.socket.nio.SocketConnector$Worker.run(SocketConnector.java:395)
> at
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:43)
> at java.lang.Thread.run(Thread.java:595)
> Caused by: java.net.SocketException: Invalid argument:
> sun.nio.ch.Net.setIntOption
> at sun.nio.ch.Net.setIntOption0(Native Method)
> at sun.nio.ch.Net.setIntOption(Net.java:152)
> at sun.nio.ch.SocketChannelImpl$1.setInt(SocketChannelImpl.java:372)
> at sun.nio.ch.SocketOptsImpl.setBoolean(SocketOptsImpl.java:38)
> at sun.nio.ch.SocketOptsImpl.keepAlive(SocketOptsImpl.java:92)
> at sun.nio.ch.OptionAdaptor.setKeepAlive(OptionAdaptor.java:139)
> at sun.nio.ch.SocketAdaptor.setKeepAlive(SocketAdaptor.java:322)
> at
> org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:248)
> ... 7 more
> I had to remove the following lines from the SocketSessionImpl constructor:
> this.config.setKeepAlive( cfg.isKeepAlive() );
> this.config.setTcpNoDelay( cfg.isTcpNoDelay() );
> and now it works.
> No matter if I change the configuration to let them return true or false, I
> keep getting the exception if I don't remove the call at all.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.