changing thrift_processor shutdown to compy with proc_lib standards
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666437 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/alterl/src/thrift_buffered_transport.erl b/lib/alterl/src/thrift_buffered_transport.erl
index 855a186..702d352 100644
--- a/lib/alterl/src/thrift_buffered_transport.erl
+++ b/lib/alterl/src/thrift_buffered_transport.erl
@@ -41,7 +41,6 @@
new(WrappedTransport) ->
case gen_server:start_link(?MODULE, [WrappedTransport], []) of
{ok, Pid} ->
-%% io:format("buffered transport ~p wrapping ~p", [Pid, WrappedTransport]),
thrift_transport:new(?MODULE, Pid);
Else ->
Else
@@ -121,11 +120,11 @@
thrift_transport:flush(Wrapped),
{reply, Response, State#state{buffer = []}};
-handle_call(close, _From, State = #state{buffer = Buffer,
+handle_call(close, From, State = #state{buffer = Buffer,
wrapped = Wrapped}) ->
thrift_transport:write(Wrapped, concat_binary(lists:reverse(Buffer))),
- thrift_transport:close(Wrapped),
- {reply, ok, State}.
+ Close=thrift_transport:close(Wrapped),
+ {stop, shutdown, Close, State}.
%%--------------------------------------------------------------------
%% Function: handle_cast(Msg, State) -> {noreply, State} |
diff --git a/lib/alterl/src/thrift_processor.erl b/lib/alterl/src/thrift_processor.erl
index c78dda3..0eccba6 100644
--- a/lib/alterl/src/thrift_processor.erl
+++ b/lib/alterl/src/thrift_processor.erl
@@ -28,11 +28,12 @@
case thrift_protocol:read(IProto, message_begin) of
#protocol_message_begin{name = Function,
type = ?tMessageType_CALL} ->
- ok=handle_function(State, list_to_atom(Function)),
+ ok = handle_function(State, list_to_atom(Function)),
loop(State);
{error, closed} ->
%% error_logger:info_msg("Client disconnected~n"),
- exit(protocol_closed)
+ thrift_protocol:close_transport(OProto),
+ exit(shutdown)
end.
handle_function(State=#thrift_processor{in_protocol = IProto,
@@ -52,7 +53,6 @@
handle_success(State, Function, Result)
catch
Type:Data ->
- error_logger:info_msg("handle_function oh noes: ~p ~p", [Type, Data]),
handle_function_catch(State, Function, Type, Data)
end,
after_reply(OProto).
diff --git a/lib/alterl/src/thrift_socket_transport.erl b/lib/alterl/src/thrift_socket_transport.erl
index 9a27de0..4b1f723 100644
--- a/lib/alterl/src/thrift_socket_transport.erl
+++ b/lib/alterl/src/thrift_socket_transport.erl
@@ -37,4 +37,4 @@
close(#data{socket = Socket}) ->
gen_tcp:close(Socket),
- exit(protocol_closed).
+ exit(normal).
diff --git a/lib/alterl/src/thrift_transport.erl b/lib/alterl/src/thrift_transport.erl
index 6c0c663..919927d 100644
--- a/lib/alterl/src/thrift_transport.erl
+++ b/lib/alterl/src/thrift_transport.erl
@@ -16,7 +16,7 @@
{close, 1}
].
--record(transport, { module, data }).
+-record(transport, {module, data}).
new(Module, Data) when is_atom(Module) ->
{ok, #transport{module = Module,