couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r805792 - /couchdb/trunk/src/couchdb/couch_rep_reader.erl
Date Wed, 19 Aug 2009 13:18:34 GMT
Author: kocolosk
Date: Wed Aug 19 13:18:33 2009
New Revision: 805792

URL: http://svn.apache.org/viewvc?rev=805792&view=rev
Log:
maybe reopen source to get newer documents

Modified:
    couchdb/trunk/src/couchdb/couch_rep_reader.erl

Modified: couchdb/trunk/src/couchdb/couch_rep_reader.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_reader.erl?rev=805792&r1=805791&r2=805792&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep_reader.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_reader.erl Wed Aug 19 13:18:33 2009
@@ -223,17 +223,25 @@
             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(),



Mime
View raw message