From 80664fe23327544bfdfdee9a8f38f61761d5641e Mon Sep 17 00:00:00 2001 From: David Reiss Date: Wed, 11 Jun 2008 01:00:30 +0000 Subject: [PATCH] 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 --- lib/alterl/src/thrift_buffered_transport.erl | 7 +++---- lib/alterl/src/thrift_processor.erl | 6 +++--- lib/alterl/src/thrift_socket_transport.erl | 2 +- lib/alterl/src/thrift_transport.erl | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/alterl/src/thrift_buffered_transport.erl b/lib/alterl/src/thrift_buffered_transport.erl index 855a1869..702d352e 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 @@ handle_call(flush, _From, State = #state{buffer = Buffer, 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 c78dda34..0eccba6e 100644 --- a/lib/alterl/src/thrift_processor.erl +++ b/lib/alterl/src/thrift_processor.erl @@ -28,11 +28,12 @@ loop(State = #thrift_processor{in_protocol = IProto, 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_function(State=#thrift_processor{in_protocol = IProto, 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 9a27de04..4b1f723f 100644 --- a/lib/alterl/src/thrift_socket_transport.erl +++ b/lib/alterl/src/thrift_socket_transport.erl @@ -37,4 +37,4 @@ flush(_) -> 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 6c0c6633..919927d8 100644 --- a/lib/alterl/src/thrift_transport.erl +++ b/lib/alterl/src/thrift_transport.erl @@ -16,7 +16,7 @@ behaviour_info(callbacks) -> {close, 1} ]. --record(transport, { module, data }). +-record(transport, {module, data}). new(Module, Data) when is_atom(Module) -> {ok, #transport{module = Module, -- 2.17.1