-behaviour(gen_server).
%% API
--export([start_link/3, call/3]).
+-export([start_link/3, call/3, close/1]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
{exception, Exception} -> throw(Exception)
end.
+close(Client) when is_pid(Client) ->
+ gen_server:call(Client, close).
+
%%====================================================================
%% gen_server callbacks
%%====================================================================
end
end,
- {reply, Result, State}.
+ {reply, Result, State};
+handle_call(close, _From, State = #state{protocol = Protocol}) ->
+ {stop, shutdown, ok, State}.
%%--------------------------------------------------------------------
%% Function: handle_cast(Msg, State) -> {noreply, State} |
%% cleaning up. When it returns, the gen_server terminates with Reason.
%% The return value is ignored.
%%--------------------------------------------------------------------
-terminate(_Reason, _State) ->
+terminate(_Reason, State = #state{protocol = Protocol}) ->
+ thrift_protocol:close_transport(Protocol),
ok.
%%--------------------------------------------------------------------