[thrift] Erlang Thrift changes, take 3
Summary: svn ci missed a bunch of paths ... blew away the whole thing and copied from the git repo. this is getting ridiculous.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665285 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/src/thrift.app.src b/lib/erl/src/thrift.app.src
old mode 100755
new mode 100644
diff --git a/lib/erl/src/thrift.appup.src b/lib/erl/src/thrift.appup.src
old mode 100755
new mode 100644
diff --git a/lib/erl/src/thrift_app.erl b/lib/erl/src/thrift_app.erl
new file mode 100644
index 0000000..dabc7ed
--- /dev/null
+++ b/lib/erl/src/thrift_app.erl
@@ -0,0 +1,25 @@
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(thrift_app).
+
+-export([start/2, stop/1]).
+-behaviour(application).
+
+-include("thrift.hrl").
+
+%%%
+%%% behavior definition
+%%%
+
+start(_Type, _StartArgs) ->
+ io:format("starting thrift~n"),
+ thrift_logger:install(),
+ {ok, Sup} = thrift_app_sup:start_link(),
+ {ok, Sup}.
+
+stop(_State) ->
+ ok.
diff --git a/lib/erl/src/thrift_app_sup.erl b/lib/erl/src/thrift_app_sup.erl
new file mode 100644
index 0000000..3a44c3f
--- /dev/null
+++ b/lib/erl/src/thrift_app_sup.erl
@@ -0,0 +1,19 @@
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(thrift_app_sup).
+
+-behaviour(supervisor).
+
+-export([start_link/0, init/1]).
+
+-define(SERVER, ?MODULE).
+
+start_link() ->
+ supervisor:start_link({local, ?SERVER}, ?MODULE, []).
+
+init(_) ->
+ {ok, {{one_for_one,10,1}, []}}.
diff --git a/lib/erl/src/thrift_logger.erl b/lib/erl/src/thrift_logger.erl
index 6deb222..13649a5 100644
--- a/lib/erl/src/thrift_logger.erl
+++ b/lib/erl/src/thrift_logger.erl
@@ -140,7 +140,7 @@
end.
%%
-handle_event1({What, _Gleader, {Pid, Format, Data}}, State) when is_list(Format) ->
+handle_event1({What, _Gleader, {Ref, Format, Data}}, State) when is_list(Format) ->
Symbol = case What of
error -> "!!";
warning_msg -> "**";
diff --git a/lib/erl/src/thrift_sup.erl b/lib/erl/src/thrift_sup.erl
new file mode 100644
index 0000000..8f6eaf7
--- /dev/null
+++ b/lib/erl/src/thrift_sup.erl
@@ -0,0 +1,40 @@
+%%% Copyright (c) 2007- Facebook
+%%% Distributed under the Thrift Software License
+%%%
+%%% See accompanying file LICENSE or visit the Thrift site at:
+%%% http://developers.facebook.com/thrift/
+
+-module(thrift_sup).
+
+-behaviour(supervisor).
+
+-include("thrift.hrl").
+
+-export([start_link/3, init/1, thrift_start_link/7]).
+
+-define(SERVER, ?MODULE).
+
+start_link(Port, Handler, Processor) ->
+ Args = [Port, Handler, Processor],
+ supervisor:start_link({local, ?SERVER}, ?MODULE, Args).
+
+init([Port, Handler, Processor]) ->
+ TF = tBufferedTransportFactory,
+ PF = tBinaryProtocolFactory,
+ ST = tErlAcceptor,
+ SF = tErlServer,
+
+ ThriftModules = [TF, PF, ST, SF],
+
+ Args = [SF, Port, Handler, Processor, ST, TF, PF],
+
+ ThriftServer = {thrift_server, {?MODULE, thrift_start_link, Args},
+ permanent, 2000, worker, ThriftModules},
+
+ {ok, {{one_for_one, 10, 1}, [ThriftServer]}}.
+
+thrift_start_link(SF = tErlServer, Port, Hnd, Pr, ST, TF, PF) ->
+ Args = [Port, Hnd, Pr, ST, TF:new(), PF:new()],
+ Pid = oop:start_new(SF, Args),
+ ?R0(Pid, effectful_serve),
+ {ok, Pid}.