You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2008/06/11 03:02:40 UTC

svn commit: r666453 - in /incubator/thrift/trunk/lib/alterl/src: thrift_buffered_transport.erl thrift_processor.erl thrift_socket_transport.erl

Author: dreiss
Date: Tue Jun 10 18:02:39 2008
New Revision: 666453

URL: http://svn.apache.org/viewvc?rev=666453&view=rev
Log:
adding explicit timeout handling and error_logging

Modified:
    incubator/thrift/trunk/lib/alterl/src/thrift_buffered_transport.erl
    incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl
    incubator/thrift/trunk/lib/alterl/src/thrift_socket_transport.erl

Modified: incubator/thrift/trunk/lib/alterl/src/thrift_buffered_transport.erl
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/alterl/src/thrift_buffered_transport.erl?rev=666453&r1=666452&r2=666453&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/alterl/src/thrift_buffered_transport.erl (original)
+++ incubator/thrift/trunk/lib/alterl/src/thrift_buffered_transport.erl Tue Jun 10 18:02:39 2008
@@ -73,7 +73,7 @@
 %% Description: Reads data through from the wrapped transoprt
 %%--------------------------------------------------------------------
 read(Transport, Len) when is_integer(Len) ->
-    gen_server:call(Transport, {read, Len}).
+    gen_server:call(Transport, {read, Len}, _Timeout=10000).
 
 %%====================================================================
 %% gen_server callbacks

Modified: incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl?rev=666453&r1=666452&r2=666453&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl (original)
+++ incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl Tue Jun 10 18:02:39 2008
@@ -30,6 +30,9 @@
                                 type = ?tMessageType_CALL} ->
             ok = handle_function(State, list_to_atom(Function)),
             loop(State);
+        {error, timeout} ->
+            thrift_protocol:close_transport(OProto),
+            ok;
         {error, closed} ->
             %% error_logger:info_msg("Client disconnected~n"),
             thrift_protocol:close_transport(OProto),

Modified: incubator/thrift/trunk/lib/alterl/src/thrift_socket_transport.erl
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/alterl/src/thrift_socket_transport.erl?rev=666453&r1=666452&r2=666453&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/alterl/src/thrift_socket_transport.erl (original)
+++ incubator/thrift/trunk/lib/alterl/src/thrift_socket_transport.erl Tue Jun 10 18:02:39 2008
@@ -29,7 +29,13 @@
 
 read(#data{socket=Socket, recv_timeout=Timeout}, Len)
   when is_integer(Len), Len >= 0 ->
-    gen_tcp:recv(Socket, Len, Timeout).
+    case gen_tcp:recv(Socket, Len, Timeout) of
+        Err = {error, timeout} ->
+            error_logger:error_msg("read timeout for conn with ~p", [inet:peername(Socket)]),
+            gen_tcp:close(Socket),
+            Err;
+        Data -> Data
+    end.
 
 %% We can't really flush - everything is flushed when we write
 flush(_) ->