Possible bug in NIO DatagramChannel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have been fighting with a small piece of code that fails with Cacao
and JamVM with GNU classlib 0.97.2, but works as expected with SUN and
IBM JVMs as well as if compiled into native using GCJ.

I managed to nail it down to the following small piece of code
(exception handling omitted):

Selector selector = Selector.open();
DatagramChannel dc = DatagramChannel.open();
dc.configureBlocking(false);
dc.socket().bind(socketAddress);
dc.register(selector, SelectionKey.OP_READ);
selector.select();

Selector is not interrupted when datagrams are sent to the address
specified. strace shows that two sockets are opened and bind is called
on the second one, but select is executed with the first socket.

In the code I am noticing that gnu.java.nio.DatagramChannelImpl and
gnu.java.net.PlainDatagramSocketImpl both have private channel members
of class VMChannel and channel.initSocket(false) is called for both
causing two sockets to be created.

First during DatagramChannel.open() DatagramChannelImpl constructor does
channel.initSocket(false) creating the first socket. Then during
dc.socket().bind(socketAddress) another socket  is created by
PlainDatagramSocketImpl. Then bind is called on the second socket.

Select, however, operates on the first socket and it never acts on
incoming packets.

I an not familiar with the code well enough to propose a solution. Does
anybody have a comment on the findings and a  recommendation on how to
fix this issue?

Thanks,
Mark.




[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux