2 problem about udp
"Trustin Lee (이희승)"
trustin at gmail.com
Sun Jun 6 22:15:04 EDT 2010
Hi, Yanliang,
The infinite loop problem in the NIO UDP transport has been fixed. Let
me release the next version soon.
Regarding the blocked thread with OIO UDP, I'd like to know what the
full thread dump looked like at the moment. I believe it's an issue
with O/S though. Let me stay tuned for your additional information.
HTH,
Trustin
lyl wrote:
> Hi Trustin Lee,
>
> I meet 2 problems about netty udp:
>
> 1) About OIO udp. Thread can be blocked for seconds after creating dozens of
> channels. But NIO doesn't have this problem. The test code is as below:
>
> ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(new
> OioDatagramChannelFactory(Executors.newCachedThreadPool()));
>
> // After creating some channels, the thread is paused for some seconds,
> very strange...
> for (int i = 0; i < 500; i++) {
>
> DatagramChannel channel = (DatagramChannel)bootstrap.bind(new
> InetSocketAddress(0));
>
> channel.connect(new InetSocketAddress("10.72.4.94", 5000));
>
> System.out.println(i);
> }
>
>
>
> 2) Also about udp, but is NIO mode. I tried to send empty data with udp,
> which lead to OIO work thread dead loop. The test code is as below:
>
> ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(new
> NioDatagramChannelFactory(Executors
> .newCachedThreadPool()));
> DatagramChannel channel = (DatagramChannel) bootstrap.bind(new
> InetSocketAddress(0));
>
> byte[] bytes = new byte[0];
>
> ChannelBuffer channelBuffer = ChannelBuffers.wrappedBuffer(bytes);
>
> channel.write(channelBuffer, new InetSocketAddress("192.168.0.190",
> 8000)).awaitUninterruptibly();
>
> // The program can not execute to here...
>
> System.out.println("ok");
>
>
>
> After simple debug, I found the dead loop lies here:
>
> NioDatagramWork(line:533)
> ...
> for (int i = writeSpinCount; i > 0; i --) {
> localWrittenBytes = buf.transferTo(ch);
> if (localWrittenBytes != 0) {
> writtenBytes += localWrittenBytes;
> break;
> }
> }
> ...
> Because the data length is 0, so the "localWrittenBytes != 0" would never
> meet. Is the problem here?
>
>
> Above is the problem I meet, any reply is appreciated.
>
> Best regards!
>
> Lu Yanliang
>
--
what we call human nature in actuality is human habit
http://gleamynode.net/
More information about the netty-users
mailing list