Mercurial > hg > Database > Alice
diff src/alice/daemon/IncomingTcpConnection.java @ 16:433e601a8e28
network bug fix
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jan 2012 12:17:30 +0900 |
parents | e3f1b21718b0 |
children | bb075e103cd3 |
line wrap: on
line diff
--- a/src/alice/daemon/IncomingTcpConnection.java Sun Jan 15 01:19:54 2012 +0900 +++ b/src/alice/daemon/IncomingTcpConnection.java Sun Jan 15 12:17:30 2012 +0900 @@ -28,11 +28,11 @@ while (true) { SocketChannel ch = connection.socket.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(4); // for int - try { int allReadLen = 0; do { int readLen = ch.read(buf); + if (readLen < 0) return; allReadLen += readLen; } while (allReadLen < 4); buf.rewind(); @@ -41,12 +41,15 @@ ByteBuffer msgBuf = ByteBuffer.allocateDirect(msgLen); do { int readLen = ch.read(msgBuf); + if (readLen < 0) return; allReadLen += readLen; } while (allReadLen < msgLen); - msgBuf.rewind(); + msgBuf.flip(); CommandMessage msg = msgpack.read(msgBuf, CommandMessage.class); + msgBuf.flip(); + System.out.println(msgpack.read(msgBuf)); CommandType type = CommandType.getCommandTypeFromId(msg.type); - LocalDataSegmentManager lmanager = (LocalDataSegmentManager)DataSegment.get("local"); + LocalDataSegmentManager lmanager = (LocalDataSegmentManager)DataSegment.get("local"); DataSegmentKey dsKey = lmanager.getDataSegmentKey(msg.key); switch (type) { case UPDATE: