Skip to content
Browse files

Fixed write for large responses

Large responses need more than a single write() because they cannot fix
into the socket buffers

Change-Id: Ibf5839a303f15f58c7c7d46860efccb8c6518061
Reviewed-on: http://review.couchbase.org/13558
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information...
1 parent c711703 commit 32e40aa5c051417a45482b9a84d7c39c4e30e9be @mnunberg mnunberg committed with avsej Feb 23, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/main/java/org/couchbase/mock/memcached/MemcachedServer.java
View
6 src/main/java/org/couchbase/mock/memcached/MemcachedServer.java
@@ -239,7 +239,11 @@ public void run() {
if (key.isWritable()) {
ByteBuffer buf;
while ((buf = client.getOutputBuffer()) != null) {
- if (channel.write(buf) == -1) {
+ int wv;
+ do {
+ wv = channel.write(buf);
+ } while (wv > 0);
+ if (wv == -1) {
channel.close();
throw new ClosedChannelException();
}

0 comments on commit 32e40aa

Please sign in to comment.
Something went wrong with that request. Please try again.