small buffered_transport and client improvements
moved close of wrapped transport into terminate/2
made thrift_client:close into a cast rather than call
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666444 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/alterl/src/thrift_client.erl b/lib/alterl/src/thrift_client.erl
index 3c6a167..52c65d2 100644
--- a/lib/alterl/src/thrift_client.erl
+++ b/lib/alterl/src/thrift_client.erl
@@ -44,7 +44,7 @@
end.
close(Client) when is_pid(Client) ->
- gen_server:call(Client, close).
+ gen_server:cast(Client, close).
%%====================================================================
%% gen_server callbacks
@@ -104,10 +104,7 @@
end
end,
- {reply, Result, State};
-
-handle_call(close, _From, State = #state{protocol = Protocol}) ->
- {stop, shutdown, ok, State}.
+ {reply, Result, State}.
%%--------------------------------------------------------------------
%% Function: handle_cast(Msg, State) -> {noreply, State} |
@@ -115,6 +112,9 @@
%% {stop, Reason, State}
%% Description: Handling cast messages
%%--------------------------------------------------------------------
+handle_cast(close, State=#state{protocol = Protocol}) ->
+%% error_logger:info_msg("thrift_client ~p received close", [self()]),
+ {stop,normal,State};
handle_cast(_Msg, State) ->
{noreply, State}.
@@ -134,7 +134,8 @@
%% cleaning up. When it returns, the gen_server terminates with Reason.
%% The return value is ignored.
%%--------------------------------------------------------------------
-terminate(_Reason, State = #state{protocol = Protocol}) ->
+terminate(Reason, State = #state{protocol = Protocol}) ->
+%% error_logger:info_msg("thrift_client ~p terminating due to ~p", [self(), Reason]),
thrift_protocol:close_transport(Protocol),
ok.