zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raúl Gutiérrez Segalés <...@itevenworks.net>
Subject Re: Possible logic error in ClientCnxnSocketNIO
Date Tue, 25 Nov 2014 17:49:53 GMT
Hi Robin,

On 24 November 2014 at 17:10, Robin <rchzzjcn@163.com> wrote:

> Hi,
> When SASL authentication is enabled, the ZooKeeper client will finally
> call ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
> @Override
> void sendPacket(Packet p) throws IOException {
>     SocketChannel sock = (SocketChannel) sockKey.channel();
>     if (sock == null) {
>         throw new IOException("Socket is null!");
>     }
>     p.createBB();
>     ByteBuffer pbb = p.bb;
>     sock.write(pbb);
> }
>
> One problem I can see is that the sock is non-blocking, so when the sock's
> output buffer is full(theoretically), only part of the Packet is sent out
> and the communication will break.
>

I think you are right, because that socket is set to non-blocking:

https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/ClientCnxnSocketNIO.java#L267

So it looks like the sock.write call should be wrapped into something like:

  while (pbb.remaining() > 0) {
      sock.write(pbb);
  }

Do you mind filing a ticket for this? Thanks!


-rgs

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message