Hello,
MINA 1.1.7
OS: WinXP, Unix
PC with more than one processor
I am trying to implement synchonized call from TCP Client to TCP Server and got
some synch errors.
Especially it occurs on mashines with more then one processor.
It is not always reproduced - some times it works normal :)
Use case is simple: client send message to server and wait while server respond
in the same session.
Details are skipped:
Client:
WriteFuture writeFuture = session.write(message);
writeFuture.join();
waitForResponse(); // wait for response with mutex which will be notifyed
in client handler in messageReceived method
Server handler:
public void messageReceived(IoSession session, Object message) throws
Exception
{
WriteFuture writeFuture = session.write(msg);
writeFuture.join();
}
- Sometimes it works normal;
- In some cases client blocks in writeFuture.join(); when server responds to
fast.
I see that in traces: client not finished sending and already receiving data.
- Some times client wrote message successfully, but server blocks in
writeFuture.join();
- And some times exception occurs:
2008-07-14 19:45:26,619 [oProcessor-35.0] WARN DefaultExceptionMonitor
- Unexpected exception.
java.nio.InvalidMarkException
at java.nio.Buffer.reset(Buffer.java:280)
at org.apache.mina.common.support.BaseByteBuffer.reset(BaseByteBuffer.java:154)
at org.apache.mina.common.ByteBufferProxy.reset(ByteBufferProxy.java:108)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoProcessor.java:402)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoProcessor.java:332)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.access$500(SocketIoProcessor.java:45)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:488)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.lang.Thread.run(Thread.java:595)
So, can you help me to resolve such synch issues or it is internal MINA defect.
>From the first look I can assume that some flags, switchs, marks, etc. not
>properly changed by input/output threads.
I also saw an article
http://markmail.org/search/?q=java.nio.InvalidMarkException#query:java.nio.InvalidMarkException+page:1+mid:7lslu7lwuckxmavj+state:results
Partially it is looks like the same problem there.
Thank you in advance.
-------------------------
Sergey Mamitko [EMAIL PROTECTED]
ISD, http://www.isd.dp.ua/index.html.en