Skip to content

Commit

Permalink
[#133] addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ferigis committed Jan 27, 2017
1 parent 2d28207 commit e989444
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/apns_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ default_connection(ConnectionName) ->
%% @doc Close the connection with APNs gracefully
-spec close_connection(name()) -> ok.
close_connection(ConnectionName) ->
gen_server:call(ConnectionName, stop).
gen_server:cast(ConnectionName, stop).

%% @doc Returns the gun's connection PID. This function is only used in tests.
-spec gun_connection(name()) -> pid().
Expand All @@ -119,13 +119,13 @@ init(Connection) ->
) -> {reply, ok, State}.
handle_call(gun_connection, _From, #{gun_connection := GunConn} = State) ->
{reply, GunConn, State};
handle_call(stop, _From, State) ->
{stop, normal, ok, State};
handle_call(_Request, _From, State) ->
{reply, ok, State}.

-spec handle_cast(Request :: term(), State) ->
{noreply, State}.
handle_cast(stop, State) ->
{stop, normal, State};
handle_cast(_Request, State) ->
{noreply, State}.

Expand All @@ -143,9 +143,9 @@ handle_info(_Info, State) ->

-spec terminate( Reason :: (normal | shutdown | {shutdown, term()} | term())
, State :: map()
) -> term().
) -> ok.
terminate(_Reason, #{gun_connection := GunConn}) ->
ok = gun:shutdown(GunConn),
gun:shutdown(GunConn),
ok.

-spec code_change(OldVsn :: term() | {down, term()}
Expand Down
2 changes: 2 additions & 0 deletions test/connection_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ connect(_Config) ->
true = is_process_alive(ServerPid),
ServerPid = whereis(ConnectionName),
ok = apns:close_connection(ConnectionName),
timer:sleep(1000),
undefined = whereis(ConnectionName),
ok.

Expand All @@ -78,6 +79,7 @@ gun_connection_crashes(_Config) ->
true = is_process_alive(GunPid2),
true = (GunPid =/= GunPid2),
ok = apns:close_connection(ConnectionName),
timer:sleep(1000),
false = is_process_alive(GunPid2),
[_] = meck:unload(),
ok.
Expand Down

0 comments on commit e989444

Please sign in to comment.