Permalink
Browse files

Fix async view fetch

Fix case in async fetch with include_docs, when last chunk arrives
after last doc fetched.

Change-Id: Ia022d69c9a82ab80be08ec022d623ba510f5d485
Reviewed-on: http://review.couchbase.org/23991
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information...
1 parent 71702c1 commit 48538aae4fde5f9f9a8bd9b57dba3f357a11556f @funny-falcon funny-falcon committed with avsej Jan 16, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/couchbase/view.rb
View
@@ -106,6 +106,7 @@ def push(obj)
def complete!
if @include_docs
@completed = true
+ check_for_ready_documents
elsif !@queue.empty?
obj = @queue.shift
obj[S_IS_LAST] = true
@@ -122,7 +123,8 @@ def block_call(obj)
def check_for_ready_documents
shift = @shift
queue = @queue
- while @first < queue.size + shift
+ save_last = @completed ? 0 : 1
+ while @first < queue.size + shift - save_last
obj = queue[@first - shift]
break unless obj[S_DOC]
queue[@first - shift] = nil

0 comments on commit 48538aa

Please sign in to comment.