couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [3/4] couch-index commit: updated refs/heads/master to 0c5f25b
Date Wed, 04 Feb 2015 15:49:47 GMT
Update config_listener behaviuor

COUCHDB-2561


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/3aa6a195
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/3aa6a195
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/3aa6a195

Branch: refs/heads/master
Commit: 3aa6a19552eece95df0969c98af143fe6090c8f0
Parents: eb61626
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Thu Jan 29 13:40:27 2015 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed Feb 4 06:07:37 2015 -0800

----------------------------------------------------------------------
 src/couch_index.erl        | 14 ++++++--------
 src/couch_index_server.erl | 15 ++++++++-------
 2 files changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/3aa6a195/src/couch_index.erl
----------------------------------------------------------------------
diff --git a/src/couch_index.erl b/src/couch_index.erl
index b44d351..509053b 100644
--- a/src/couch_index.erl
+++ b/src/couch_index.erl
@@ -25,7 +25,7 @@
 -export([handle_call/3, handle_cast/2, handle_info/2]).
 
 % config_listener api
--export([handle_config_change/5]).
+-export([handle_config_change/5, handle_config_terminate/3]).
 
 
 -include_lib("couch/include/couch_db.hrl").
@@ -297,13 +297,6 @@ handle_cast(ddoc_updated, State) ->
 handle_cast(_Mesg, State) ->
     {stop, unhandled_cast, State}.
 
-
-handle_info({gen_event_EXIT, {config_listener, ?MODULE}, _Reason}, State) ->
-    erlang:send_after(5000, self(), restart_config_listener),
-    {noreply, State};
-handle_info(restart_config_listener, State) ->
-    ok = config:listen_for_changes(?MODULE, nil),
-    {noreply, State};
 handle_info(commit, #st{committed=true}=State) ->
     {noreply, State};
 handle_info(commit, State) ->
@@ -367,6 +360,11 @@ handle_config_change("query_server_config", "commit_freq", Val, _, _)
->
 handle_config_change(_, _, _, _, _) ->
     {ok, nil}.
 
+handle_config_terminate(_Server, _Reason, _State) ->
+    spawn(fun() ->
+        timer:sleep(5000),
+        config:listen_for_changes(?MODULE, nil)
+    end).
 
 maybe_restart_updater(#st{waiters=[]}) ->
     ok;

http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/3aa6a195/src/couch_index_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_server.erl b/src/couch_index_server.erl
index 76adb6a..5e5c307 100644
--- a/src/couch_index_server.erl
+++ b/src/couch_index_server.erl
@@ -22,6 +22,7 @@
 % Exported for callbacks
 -export([
     handle_config_change/5,
+    handle_config_terminate/3,
     handle_db_event/3
 ]).
 
@@ -163,13 +164,6 @@ handle_cast({reset_indexes, DbName}, State) ->
     reset_indexes(DbName, State#st.root_dir),
     {noreply, State}.
 
-
-handle_info({gen_event_EXIT, {config_listener, ?MODULE}, _Reason}, State) ->
-    erlang:send_after(5000, self(), restart_config_listener),
-    {noreply, State};
-handle_info(restart_config_listener, State) ->
-    ok = config:listen_for_changes(?MODULE, State#st.root_dir),
-    {noreply, State};
 handle_info({'EXIT', Pid, Reason}, Server) ->
     case ets:lookup(?BY_PID, Pid) of
         [{Pid, {DbName, Sig}}] ->
@@ -204,6 +198,13 @@ handle_config_change("couchdb", "view_index_dir", _, _, _) ->
 handle_config_change(_, _, _, _, RootDir) ->
     {ok, RootDir}.
 
+handle_config_terminate(_Server, _Reason, _State) ->
+    State = couch_index_util:root_dir(),
+    spawn(fun() ->
+        timer:sleep(5000),
+        config:listen_for_changes(?MODULE, State)
+    end).
+
 new_index({Mod, IdxState, DbName, Sig}) ->
     DDocId = Mod:get(idx_name, IdxState),
     case couch_index:start_link({Mod, IdxState}) of


Mime
View raw message