GP = oop:get(This, generatedProcessor),
Handler = oop:get(This, handler),
- apply(GP, process, [Handler, Iprot, Oprot]).
+ GP:process(Handler, Iprot, Oprot).
[Pid, LastMessage, Obj, Reason] = Data,
%% TODO: move as much logic as possible out of thrift_logger
- Ignore = error /= thrift_utils:unnest_record(Reason, tTransportException),
+ Ignore = (is_tuple(Reason) andalso size(Reason) >= 1 andalso element(1, Reason) == timeout)
+ orelse error /= thrift_utils:unnest_record(Reason, tTransportException),
case Ignore of
true ->
handle_thrift_info(conn_accepted, {AddrString}, State) ->
sformat("connection accepted from ~s", [AddrString]);
+handle_thrift_info(conn_timeout, {AddrString}, State) ->
+ sformat("connection timed out from ~s", [AddrString]);
+
handle_thrift_info(conn_closed, {AddrString}, State) ->
sformat("connection closed from ~s", [AddrString]);
%% start_new(, ...)
Processor = oop:start_new(tErlProcessor, [GP, Handler]), %% TODO
- receive_loop(This, Processor, Prot, Prot),
-
- ?INFO(conn_closed, {AddrString}),
-
+ case receive_loop(This, Processor, Prot, Prot) of
+ conn_timeout ->
+ ?INFO(conn_timeout, {AddrString});
+ conn_closed ->
+ ?INFO(conn_closed, {AddrString});
+ {Class, Else} ->
+ ?ERROR("unhandled ~p in tErlAcceptor: ~p", [Class, Else])
+ end,
exit(normal);
Else ->
?INFO(req_processed, {Value}),
receive_loop(This, Processor, Iprot, Oprot)
catch
- %% the following clause must be last because we might reexit
+ exit:{timeout, _} ->
+ conn_timeout;
+
+ %% the following clause must be last
+ %% cpiro: would be best to implement an is_a/2 guard BIF
%% cpiro: breaks if it's a subclass of tTransportException
%% since unnest_record knows nothing about oop
- exit:Else ->
+ Class:Else ->
case thrift_utils:unnest_record(Else, tTransportException) of
{ok, TTE} when TTE#tTransportException.type == ?tTransportException_NOT_OPEN ->
- ok; %% will exit to tErlAcceptor
+ conn_closed;
_ ->
- exit(Else) %% shouldn't have caught it in the first place
+ {Class, Else}
end
end.