Fix thrift_server to create transport and protocol inside the processor rather than inside the acceptor.
This fixes a process and file descriptor leak -- previously, the thrift_buffered_transport process was linked to the acceptor, which never died.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666409 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/alterl/src/thrift_server.erl b/lib/alterl/src/thrift_server.erl
index e5c9cf9..a639eb0 100644
--- a/lib/alterl/src/thrift_server.erl
+++ b/lib/alterl/src/thrift_server.erl
@@ -120,11 +120,15 @@
{ok, Socket} = gen_tcp:accept(ListenSocket),
error_logger:info_msg("Accepted client"),
- {ok, SocketTransport} = thrift_socket_transport:new(Socket),
- {ok, BufferedTransport} = thrift_buffered_transport:new(SocketTransport),
- {ok, Protocol} = thrift_binary_protocol:new(BufferedTransport),
- thrift_processor:start(Protocol, Protocol, Service, Handler),
+ ProtoGen = fun() ->
+ {ok, SocketTransport} = thrift_socket_transport:new(Socket),
+ {ok, BufferedTransport} = thrift_buffered_transport:new(SocketTransport),
+ {ok, Protocol} = thrift_binary_protocol:new(BufferedTransport),
+ {ok, Protocol, Protocol}
+ end,
+
+ thrift_processor:start(ProtoGen, Service, Handler),
receive
refresh ->
error_logger:info_msg("Acceptor refreshing~n"),