Skip to content

Commit

Permalink
fix view closing.
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Sep 29, 2009
1 parent a2a88eb commit 0a98722
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/couchbeam.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
db,
couchdb = #couchdb_params{},
base,
name,
params=[],
fetched=false,
total_rows=0,
Expand Down
16 changes: 11 additions & 5 deletions src/couchbeam_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ count(ViewPid, Refresh) ->
gen_server:call(ViewPid, {count, Refresh}, infinity).

close_view(ViewPid) ->
handle:cast(ViewPid, close_view).
catch exit(ViewPid, kill),
ok.

%%---------------------------------------------------------------------------
%% gen_server callbacks
Expand All @@ -68,7 +69,8 @@ init({Vname, Params, #db{server=ServerState, couchdb=CouchdbParams, base=BaseDB}
end,
ViewState = #view{server = ServerState,
couchdb = CouchdbParams,
db = DbState,
db = DbState,
name = Vname,
base = Base,
params = Params},
{ok, ViewState}.
Expand All @@ -93,14 +95,18 @@ handle_call({count, Refresh}, _From, State) ->
true -> length(Rows);
false -> 0
end,
{reply, Count, NewState}.
{reply, Count, NewState};

handle_cast(close_view, State) ->
{stop, State};
handle_call(stop_view, _From, State) ->
{stop, ok, State}.

handle_cast(_Msg, State) ->
{no_reply, State}.


handle_info({'EXIT', _Pid, _Reason}, State) ->
io:format("Stopping view ~p ~n", [State#view.name]),
{noreply, State};
handle_info(_Info, State) ->
{noreply, State}.

Expand Down

0 comments on commit 0a98722

Please sign in to comment.