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