You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 23:08:39 UTC

[25/32] git commit: Make couch_view_updater amenable to hot upgrades

Make couch_view_updater amenable to hot upgrades


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/commit/ab00ad0d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/ab00ad0d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/ab00ad0d

Branch: refs/heads/import
Commit: ab00ad0d81158e95df33792310afd4354e088206
Parents: 2f60ab9
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Mon Aug 9 09:53:16 2010 -0400
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Mar 20 06:02:46 2013 -0500

----------------------------------------------------------------------
 src/couch_index_updater.erl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/ab00ad0d/src/couch_index_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_updater.erl b/src/couch_index_updater.erl
index e6da4e5..057db16 100644
--- a/src/couch_index_updater.erl
+++ b/src/couch_index_updater.erl
@@ -17,6 +17,9 @@
 %% API
 -export([start_link/2, run/2, is_running/1, update/2, restart/2]).
 
+%% for upgrades
+-export([update/3]).
+
 %% gen_server callbacks
 -export([init/1, terminate/2, code_change/3]).
 -export([handle_call/3, handle_cast/2, handle_info/2]).
@@ -65,7 +68,7 @@ handle_call({update, _IdxState}, _From, #st{pid=Pid}=State) when is_pid(Pid) ->
 handle_call({update, IdxState}, _From, #st{idx=Idx, mod=Mod}=State) ->
     Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
     ?LOG_INFO("Starting index update for db: ~s idx: ~s", Args),
-    Pid = spawn_link(fun() -> update(Idx, Mod, IdxState) end),
+    Pid = spawn_link(?MODULE, update, [Idx, Mod, IdxState]),
     {reply, ok, State#st{pid=Pid}};
 handle_call({restart, IdxState}, _From, #st{idx=Idx, mod=Mod}=State) ->
     Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
@@ -74,7 +77,7 @@ handle_call({restart, IdxState}, _From, #st{idx=Idx, mod=Mod}=State) ->
         true -> couch_util:shutdown_sync(State#st.pid);
         _ -> ok
     end,
-    Pid = spawn_link(fun() -> update(Idx, State#st.mod, IdxState) end),
+    Pid = spawn_link(?MODULE, update, [Idx, State#st.mod, IdxState]),
     {reply, ok, State#st{pid=Pid}};
 handle_call(is_running, _From, #st{pid=Pid}=State) when is_pid(Pid) ->
     {reply, true, State};
@@ -94,7 +97,7 @@ handle_info({'EXIT', _, {updated, Pid, IdxState}}, #st{pid=Pid}=State) ->
     {noreply, State#st{pid=undefined}};
 handle_info({'EXIT', _, {reset, Pid}}, #st{idx=Idx, pid=Pid}=State) ->
     {ok, NewIdxState} = gen_server:call(State#st.idx, reset),
-    Pid2 = spawn_link(fun() -> update(Idx, State#st.mod, NewIdxState) end),
+    Pid2 = spawn_link(?MODULE, update, [Idx, State#st.mod, NewIdxState]),
     {noreply, State#st{pid=Pid2}};
 handle_info({'EXIT', Pid, normal}, #st{pid=Pid}=State) ->
     {noreply, State#st{pid=undefined}};