diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2009-08-19 13:18:33 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2009-08-19 13:18:33 +0000 |
commit | 1b59e6f8105ac88965900e63b7b4d5fc274d4db2 (patch) | |
tree | 46544899a338d05269356d10ba8319ab69c96a67 /src/couchdb | |
parent | 8eaa5d03b674f3d7d0ffd108e8ccea394261a18b (diff) |
maybe reopen source to get newer documents
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@805792 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/couch_rep_reader.erl | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/couchdb/couch_rep_reader.erl b/src/couchdb/couch_rep_reader.erl index bcb971bb..a5a1fecd 100644 --- a/src/couchdb/couch_rep_reader.erl +++ b/src/couchdb/couch_rep_reader.erl @@ -223,17 +223,25 @@ reader_loop(ReaderServer, Source, MissingRevsServer) -> N = length(IdsRevs), gen_server:call(ReaderServer, {set_monitor_count, HighSeq, N}), [gen_server:call(ReaderServer, {open_doc_revs, Id, Revs, HighSeq}) - || {Id,Revs} <- IdsRevs]; + || {Id,Revs} <- IdsRevs], + reader_loop(ReaderServer, Source, MissingRevsServer); _Local -> + Source2 = maybe_reopen_db(Source, HighSeq), lists:foreach(fun({Id,Revs}) -> - {ok, Docs} = couch_db:open_doc_revs(Source, Id, Revs, [latest]), + {ok, Docs} = couch_db:open_doc_revs(Source2, Id, Revs, [latest]), JustTheDocs = [Doc || {ok, Doc} <- Docs], gen_server:call(ReaderServer, {add_docs, JustTheDocs}) end, IdsRevs), - gen_server:call(ReaderServer, {update_high_seq, HighSeq}) + gen_server:call(ReaderServer, {update_high_seq, HighSeq}), + reader_loop(ReaderServer, Source2, MissingRevsServer) end - end, - reader_loop(ReaderServer, Source, MissingRevsServer). + end. + +maybe_reopen_db(#db{update_seq=OldSeq} = Db, HighSeq) when HighSeq > OldSeq -> + {ok, NewDb} = couch_db:open(Db#db.name, [{user_ctx, Db#db.user_ctx}]), + NewDb; +maybe_reopen_db(Db, _HighSeq) -> + Db. spawn_document_request(Source, Id, Revs) -> Server = self(), |