THRIFT-3423 First call to thrift_transport:read_exact fails to dispatch correct function

Client: Erlang
Patch: Nobuaki Sukegawa

This closes #694
This commit is contained in:
Nobuaki Sukegawa 2015-11-14 18:49:45 +09:00
parent 7f404fdef2
commit 97a48988de

View File

@ -101,11 +101,14 @@ when is_integer(Len), Len >= 0 ->
read_exact(Transport = #t_transport{module = Module}, Len)
when is_integer(Len), Len >= 0 ->
case erlang:function_exported(Module, read_exact, 2) of
true ->
{NewState, Result} = Module:read_exact(Transport#t_transport.state, Len),
{Transport#t_transport{state = NewState}, Result};
false -> read(Transport, Len)
case lists:keyfind(read_exact, 1, Module:module_info(exports)) of
{read_exact, 2} ->
io:fwrite("HAS EXACT"),
{NewState, Result} = Module:read_exact(Transport#t_transport.state, Len),
{Transport#t_transport{state = NewState}, Result};
_ ->
io:fwrite("~p NO EXACT", [Module]),
read(Transport, Len)
end.