diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/couch/src/couch_db.erl | 8 | ||||
-rw-r--r-- | apps/couch/src/couch_view_group.erl | 15 |
2 files changed, 20 insertions, 3 deletions
diff --git a/apps/couch/src/couch_db.erl b/apps/couch/src/couch_db.erl index e8a0824c..96c49886 100644 --- a/apps/couch/src/couch_db.erl +++ b/apps/couch/src/couch_db.erl @@ -112,8 +112,12 @@ open_ref_counted(MainPid, OpenedPid) -> gen_server:call(MainPid, {open_ref_count, OpenedPid}). is_idle(#db{compactor_pid=nil, waiting_delayed_commit=nil} = Db) -> - {monitored_by, Pids} = erlang:process_info(Db#db.fd, monitored_by), - (Pids -- [Db#db.main_pid, whereis(couch_stats_collector)]) =:= []; + case erlang:process_info(Db#db.fd, monitored_by) of + undefined -> + true; + {monitored_by, Pids} -> + (Pids -- [Db#db.main_pid, whereis(couch_stats_collector)]) =:= [] + end; is_idle(_Db) -> false. diff --git a/apps/couch/src/couch_view_group.erl b/apps/couch/src/couch_view_group.erl index e6fac237..11cb4c60 100644 --- a/apps/couch/src/couch_view_group.erl +++ b/apps/couch/src/couch_view_group.erl @@ -14,7 +14,7 @@ -behaviour(gen_server). %% API --export([start_link/1, request_group/2, request_group_info/1]). +-export([start_link/1, request_group/2, trigger_group_update/2, request_group_info/1]). -export([open_db_group/2, open_temp_group/5, design_doc_to_view_group/1,design_root/2]). %% gen_server callbacks @@ -54,6 +54,9 @@ request_group_info(Pid) -> throw(Error) end. +trigger_group_update(Pid, RequestSeq) -> + gen_server:cast(Pid, {update_group, RequestSeq}). + % from template start_link(InitArgs) -> case gen_server:start_link(couch_view_group, @@ -153,6 +156,16 @@ handle_call(request_group_info, _From, State) -> GroupInfo = get_group_info(State), {reply, {ok, GroupInfo}, State}. +handle_cast({update_group, RequestSeq}, + #group_state{ + group=#group{current_seq=Seq}=Group, + updater_pid=nil}=State) when RequestSeq > Seq -> + Owner = self(), + Pid = spawn_link(fun()-> couch_view_updater:update(Owner, Group) end), + {noreply, State#group_state{updater_pid=Pid}}; +handle_cast({update_group, _RequestSeq}, State) -> + {noreply, State}; + handle_cast({start_compact, CompactFun}, #group_state{compactor_pid=nil} = State) -> #group_state{ |