Properly stop the repo and revwalk servers
Return the 4-tuple when asked to stop instead of the 3-tuple so we do indicate the stop was normal.
This commit is contained in:
@@ -116,7 +116,7 @@ handle_call({lookup_object, Oid}, _From, State = #state{handle=Handle}) ->
|
|||||||
Reply = geef:object_lookup(Handle, Oid),
|
Reply = geef:object_lookup(Handle, Oid),
|
||||||
{reply, Reply, State};
|
{reply, Reply, State};
|
||||||
handle_call(stop, _From, State) ->
|
handle_call(stop, _From, State) ->
|
||||||
{stop, normal, State};
|
{stop, normal, ok, State};
|
||||||
handle_call(revwalk, _From, State = #state{handle=Handle}) ->
|
handle_call(revwalk, _From, State = #state{handle=Handle}) ->
|
||||||
Reply = handle_revwalk(Handle),
|
Reply = handle_revwalk(Handle),
|
||||||
{reply, Reply, State};
|
{reply, Reply, State};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([start_link/1]).
|
-export([start_link/1]).
|
||||||
-export([push/2, hide/2, next/1, sorting/2]).
|
-export([push/2, hide/2, next/1, sorting/2, stop/1]).
|
||||||
|
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||||
@@ -49,6 +49,10 @@ sorting(Pid, Opt) when is_atom(Opt) ->
|
|||||||
next(Pid) ->
|
next(Pid) ->
|
||||||
gen_server:call(Pid, next).
|
gen_server:call(Pid, next).
|
||||||
|
|
||||||
|
%% @doc Stop the revwalk server
|
||||||
|
stop(Pid) ->
|
||||||
|
gen_server:call(Pid, stop).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Starts the server
|
%% Starts the server
|
||||||
@@ -79,7 +83,9 @@ handle_call({hide, Oid}, _From, State = #state{handle=Handle}) ->
|
|||||||
{reply, Reply, State};
|
{reply, Reply, State};
|
||||||
handle_call(next, _From, State = #state{handle=Handle}) ->
|
handle_call(next, _From, State = #state{handle=Handle}) ->
|
||||||
Reply = handle_next(Handle),
|
Reply = handle_next(Handle),
|
||||||
{reply, Reply, State}.
|
{reply, Reply, State};
|
||||||
|
handle_call(stop, _From, State) ->
|
||||||
|
{stop, normal, ok, State}.
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
|
|||||||
@@ -22,5 +22,5 @@ odb_write_test(Repo) ->
|
|||||||
Expected = geef_oid:parse("c300118399f01fe52b316061b5d32beb27e0adfd"),
|
Expected = geef_oid:parse("c300118399f01fe52b316061b5d32beb27e0adfd"),
|
||||||
[?_assertEqual(Actual, Expected)].
|
[?_assertEqual(Actual, Expected)].
|
||||||
|
|
||||||
stop(_Repo) ->
|
stop(Repo) ->
|
||||||
ok.
|
geef_repo:stop(Repo).
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ amount_test(Repo) ->
|
|||||||
{ok, Walk} = geef_repo:revwalk(Repo),
|
{ok, Walk} = geef_repo:revwalk(Repo),
|
||||||
Id = geef_oid:parse("a4a7dce85cf63874e984719f4fdd239f5145052f"),
|
Id = geef_oid:parse("a4a7dce85cf63874e984719f4fdd239f5145052f"),
|
||||||
ok = geef_revwalk:push(Walk, Id),
|
ok = geef_revwalk:push(Walk, Id),
|
||||||
[?_assertEqual(6, count_walk(Walk, 0))].
|
Count = count_walk(Walk, 0),
|
||||||
|
geef_revwalk:stop(Walk),
|
||||||
|
[?_assertEqual(6, Count)].
|
||||||
|
|
||||||
stop(_Repo) ->
|
stop(Repo) ->
|
||||||
ok.
|
geef_repo:stop(Repo).
|
||||||
|
|||||||
Reference in New Issue
Block a user