From fa0c85737036e53728aab46dcda242d113f926be Mon Sep 17 00:00:00 2001 From: Christopher Piro Date: Sat, 11 Aug 2007 01:15:57 +0000 Subject: [PATCH] [thrift] erlang: log more tTransportExceptions Summary: all tTEs were being filtered from the logs; now just tTEs that come from connections closing are suppressed Test Plan: logs my bug in channel server :) Notes: adds logic to thrift_logger, not removes (bad news bears) git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665199 13f79535-47bb-0310-9956-ffa450edef68 --- lib/erl/lib/thrift/src/thrift_logger.erl | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/erl/lib/thrift/src/thrift_logger.erl b/lib/erl/lib/thrift/src/thrift_logger.erl index 82ba772e..12aa0596 100644 --- a/lib/erl/lib/thrift/src/thrift_logger.erl +++ b/lib/erl/lib/thrift/src/thrift_logger.erl @@ -10,6 +10,15 @@ -include("thrift_logger.hrl"). +%% TODO(cpiro): either +%% make exceptions know whether they need to be displayed +%% or not exit with tExecptions for non-errors +%% or "register" tExceptions with the logger (I LIKE!) +%% ... we shouldn't need to build any specifics in here +-include("thrift.hrl"). +-include("oop.hrl"). +-include("transport/tTransportException.hrl"). + %% gen_event callbacks -export([init/1, handle_event/2, handle_call/2, handle_info/2, terminate/2, code_change/3]). @@ -138,8 +147,20 @@ handle_event1({What, _Gleader, {Pid, Format, Data}}, State) when is_list(Format) [Pid, LastMessage, Obj, Reason] = Data, %% TODO: move as much logic as possible out of thrift_logger - Ignore = (is_tuple(Reason) andalso size(Reason) >= 1 andalso element(1, Reason) == timeout) - orelse error /= thrift_utils:unnest_record(Reason, tTransportException), + Ignore = + begin + is_tuple(Reason) andalso + size(Reason) >= 1 andalso element(1, Reason) == timeout + end + orelse + begin + case thrift_utils:unnest_record(Reason, tTransportException) of + error -> false; + {ok, TTE} -> + oop:get(TTE, type) == ?tTransportException_NOT_OPEN andalso + oop:get(TTE, message) == "in tSocket:read/2: gen_tcp:recv" + end + end, case Ignore of true -> -- 2.17.1