tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filip Hanik" <m...@filip.net>
Subject RE: deadlock in cluster module's TcpReplicationThread.java?
Date Wed, 21 May 2003 00:50:36 GMT
let me know when you find a JDK implementation that doesn't handle this
well, and I will rewrite it :)
so far I've had great results with it, most of the implementations are
having problem with the wakeup method, hence there is a flag for timing out
the select() statement.

filip

> -----Original Message-----
> From: Jim Carlson [mailto:jcarlson@jnous.com]
> Sent: Tuesday, May 20, 2003 4:58 PM
> To: tomcat-dev@jakarta.apache.org
> Subject: deadlock in cluster module's TcpReplicationThread.java?
>
>
> I have a concern about some logic in
> org/apache/catalina/cluster/tcp/TcpReplicationThread.java.
> Specifically, this code:
>
>      void drainChannel (SelectionKey key)
>          throws Exception
>      {
> 	[... snip ...]
>          // resume interest in OP_READ
>          key.interestOps (key.interestOps() | SelectionKey.OP_READ);
>          // cycle the selector so this key is active again
>          key.selector().wakeup();
>      }
>
>
> key.interestOps() is called to update the interest set on the
> selectionKey, and
> then the select is awoken.  This looks good, and it comes straight out of
> O'Reilly's "Java NIO" book (S4.5).  However, the Java API docs
> for SelectionKey
> state that:
>
> "The operations of reading and writing the interest set will, in
> general, be
> synchronized with certain operations of the selector. Exactly how this
> synchronization is performed is implementation-dependent: In a naive
> implementation, reading or writing the interest set MAY BLOCK
> INDEFINITELY if a
> selection operation is already in progress" [all-caps mine]
>
> Doesn't this mean that key.interestOps() could block for the
> duration of the
> ongoing select() call on certain NIO implementations, essentially
> resulting in
> deadlock?
>
> To be honest, I have little idea how the cluster module works or
> how important
> it is for Tomcat -- my interest is in the Java NIO pattern of
> having multiple
> threads servicing a single Selector.  I too would like to borrow
> this code from
> the O'Reilly book, but as I say, I'm worried that it isn't robust.
>
> Hopefully I'm wrong!  Any feedback is welcome.
>
> Thanks,
>
> Jim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>


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


Mime
View raw message