testing return of empty binary from 0-length thrrift read
authorDavid Reiss <dreiss@apache.org>
Wed, 11 Jun 2008 01:02:55 +0000 (01:02 +0000)
committerDavid Reiss <dreiss@apache.org>
Wed, 11 Jun 2008 01:02:55 +0000 (01:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666455 13f79535-47bb-0310-9956-ffa450edef68

lib/alterl/src/thrift_binary_protocol.erl
lib/alterl/src/thrift_socket_server.erl

index c1f9d4e..c84701e 100644 (file)
@@ -269,5 +269,6 @@ read(This, string) ->
     {ok, Sz}  = read(This, i32),
     {ok, Bin} = read(This, Sz);
 
+read(This, 0) -> {ok, <<>>};
 read(This, Len) when is_integer(Len), Len >= 0 ->
     thrift_transport:read(This#binary_protocol.transport, Len).
index 046ffca..2bb9181 100644 (file)
@@ -103,7 +103,7 @@ start_server(State=#thrift_socket_server{name=Name}) ->
     end.
 
 init(State=#thrift_socket_server{ip=Ip, port=Port}) ->
-    process_flag(trap_exit, true), %% only temporary
+    process_flag(trap_exit, true),
     BaseOpts = [binary,
                {reuseaddr, true},
                {packet, 0},
@@ -165,7 +165,7 @@ new_acceptor(State=#thrift_socket_server{acceptor=OldPid, listen=Listen,
 
 acceptor_loop({Server, Listen, Service, Handler, SocketOpts})
   when is_pid(Server), is_list(SocketOpts) ->
-    case catch gen_tcp:accept(Listen) of % infiinite timeout
+    case catch gen_tcp:accept(Listen) of % infinite timeout
        {ok, Socket} ->
            gen_server:cast(Server, {accepted, self()}),
             ProtoGen = fun() ->