Created
June 26, 2014 13:37
-
-
Save normanmaurer/25cea8247baf82ea5ab2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int pump(ByteBuf bytes) | |
| { | |
| int bytesRead = 0; | |
| try | |
| { | |
| if (bytes.readableBytes() < 8) | |
| { | |
| return 0; | |
| } | |
| synchronized (lock) | |
| { | |
| final ByteBuffer input = transport.getInputBuffer(); | |
| if (bytes.readableBytes() > input.remaining()) | |
| { | |
| for (;;) | |
| { | |
| int remaining = input.remaining(); | |
| if (remaining == 0) | |
| { | |
| System.err.println("Buffer full!!!"); | |
| break; | |
| } | |
| int min = Math.min(remaining, bytes.readableBytes()); | |
| ByteBuffer tmp = bytes.internalNioBuffer(bytes.readerIndex() + bytesRead, min); | |
| input.put(tmp); | |
| if (!processBuffer()) | |
| { | |
| System.err.println("DEBUG This.. Process Buffer returned false!!!!!!!!!!!!!"); | |
| bytesRead += min; | |
| break; | |
| } | |
| bytesRead += min; | |
| } | |
| } | |
| else | |
| { | |
| ByteBuffer tmp = bytes.internalNioBuffer(bytes.readerIndex(), bytes.readableBytes()); | |
| bytesRead = tmp.remaining(); | |
| input.put(tmp); | |
| if (!processBuffer()) return 0; | |
| } | |
| return bytesRead; | |
| } | |
| } | |
| finally | |
| { | |
| dispatch(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment