You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "ben (JIRA)" <ji...@apache.org> on 2008/09/29 22:16:44 UTC

[jira] Created: (DIRMINA-625) How to use the function awaitUninterruptibly or await

How to use the function awaitUninterruptibly or await
-----------------------------------------------------

                 Key: DIRMINA-625
                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
             Project: MINA
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0.0-M3
            Reporter: ben


Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Vadim Lotarev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12648142#action_12648142 ] 

Vadim Lotarev commented on DIRMINA-625:
---------------------------------------

This code starts working when I take it out from IoHandler.

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Closed: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny closed DIRMINA-625.
-------------------------------------


> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12647646#action_12647646 ] 

Emmanuel Lecharny commented on DIRMINA-625:
-------------------------------------------

Can you post a sample of code we can test ?

Thanks !

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Resolved: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny resolved DIRMINA-625.
---------------------------------------

    Resolution: Invalid

You can't do a future.awaitUninterruptibly() if using a single thread model, as you are waiting for the thread you are using, which is a deadlock. In other words, the thread responsible for the write is the one which doing the wait.

You have to add an ExecutorFilter in your chain to have more than one thread processing incoming requests and outgoing requests (ie, read and write).

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "ben (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635661#action_12635661 ] 

ben commented on DIRMINA-625:
-----------------------------

session.write("...").awaitUninterruptibly();

When using synchronous operation would Anomaly have

13:00:30 WARN  LoggingFilter - EXCEPTION: 
java.lang.IllegalStateException: DEAD LOCK: IoFuture.await() was invoked from an I/O processor thread.  Please use IoFutureListener or configure a proper thread model alternatively.
	at org.apache.mina.core.future.DefaultIoFuture.checkDeadLock(DefaultIoFuture.java:233)
	at org.apache.mina.core.future.DefaultIoFuture.awaitUninterruptibly(DefaultIoFuture.java:139)
	at org.apache.mina.core.future.DefaultWriteFuture.awaitUninterruptibly(DefaultWriteFuture.java:114)


The following code is the same error: 

WriteFuture wf = session.write("...").awaitUninterruptibly();
wf.addListener(new IoFutureListener<WriteFuture>(){
	@Override
	public void operationComplete(WriteFuture future) {
		// TODO Auto-generated method stub
		future.notifyAll();
	}			
});

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635513#action_12635513 ] 

Emmanuel Lecharny commented on DIRMINA-625:
-------------------------------------------

Can you be a little bit more specific? It's pretty hard to read between so few lines ...

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Vadim Lotarev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12647641#action_12647641 ] 

Vadim Lotarev commented on DIRMINA-625:
---------------------------------------

I am experiencing the same problem. The code that worked fine in 1.1.7 gets failed bein converted to 2.0 M3.

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Vadim Lotarev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12648104#action_12648104 ] 

Vadim Lotarev commented on DIRMINA-625:
---------------------------------------

Sure. I am writing a client application and sometimes I need to wait synchronously for server response. Below is the code I wrote for that (may be I did something wrong - pleas advice). Please replace RegisterClientMessage by anything else appropriate for your test sever. I do not use any thread model.

@Override
    public void sessionOpened(IoSession session) throws Exception {
        log.info(String.format("*** Connected to: %s. Local address used: %s", session.getRemoteAddress()
                .toString(), session.getLocalAddress().toString()));

        // Send REGISTERCLIENT message
        InetSocketAddress localAddress = (InetSocketAddress) session.getLocalAddress();
        RegisterClientMessage message = new RegisterClientMessage("",
                                                                  localAddress.getAddress().getHostAddress(),
                                                                  localAddress.getPort(),
                                                                  localAddress.getAddress().getHostName());

        session.getConfig().setUseReadOperation(true);
        WriteFuture writeFuture = session.write(command);
        writeFuture.awaitUninterruptibly();

        ReadFuture readFuture = session.read();
        readFuture.awaitUninterruptibly();
        session.getConfig().setUseReadOperation(false);
    }

Here is the log:

[2008-11-17 10:37:47,251] INFO  *** Connected to: [...]. Local address used:[...]
[2008-11-17 10:37:52,372] ERROR  DEAD LOCK: IoFuture.await() was invoked from an I/O processor thread.  Please use IoFutureListener or configure a proper thread model alternatively.


> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "ben (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635727#action_12635727 ] 

ben commented on DIRMINA-625:
-----------------------------

I'm using MINA 2.0 M3, version 2.0 can be set up thread  model? 

This is a server-side code, does not set any thread of things, including the thread pool

acceptor = new NioSocketAcceptor(Runtime.getRuntime().availableProcessors()+1);
chain = acceptor.getFilterChain();
addLogger(chain);
chain.addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"))));
IHandler handler = new MyHandler();
acceptor.setHandler(handler);
acceptor.bind(new InetSocketAddress(PORT));

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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


[jira] Commented: (DIRMINA-625) How to use the function awaitUninterruptibly or await

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635710#action_12635710 ] 

Emmanuel Lecharny commented on DIRMINA-625:
-------------------------------------------

What thread model are you using ? An orderedThreadPoolExecutor or an UnorderedthreadPoolExecutor ?

> How to use the function awaitUninterruptibly or await
> -----------------------------------------------------
>
>                 Key: DIRMINA-625
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-625
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M3
>            Reporter: ben
>
> Always reported abnormal DEAD LOCK, How to use it.

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