我想我知道幕后发生了什么。
我的Erlang代码
secret_function/2
)返回{ok,pid()}而不是简单的ok。
oneway_void
,我花了一段时间才找出问题的原因。
也许我们可以调整一下
handle_succes
在节俭中起作用,使它的行为与h一样
andle_function_catch
这就是
handle_function_catch
目前看来:
...
case {ErrType, ErrData} of
_ when IsOneway ->
Stack = erlang:get_stacktrace(),
error_logger:warning_msg(
"oneway void ~p threw error which must be ignored: ~p",
[Function, {ErrType, ErrData, Stack}]),
{State, ok};
...
,当引发异常时,将报告问题。根据相同的推理,一个潜在的新handle\u success函数可能如下所示:
handle_success(State = #thrift_processor{service = Service},
Function,
Result) ->
ReplyType = Service:function_info(Function, reply_type),
StructName = atom_to_list(Function) ++ "_result",
case Result of
{reply, ReplyData} when ReplyType =:= oneway_void ->
Stack = erlang:get_stacktrace(),
error_logger:warning_msg(
"oneway void ~p sent reply which must be ignored: ~p",
[Function, {ReplyData, Stack}]),
{State, ok};
{reply, ReplyData} ->
Reply = {{struct, [{0, ReplyType}]}, {StructName, ReplyData}},
send_reply(State, Function, ?tMessageType_REPLY, Reply);
ok when ReplyType == {struct, []} ->
send_reply(State, Function, ?tMessageType_REPLY, {ReplyType, {StructName}});
ok when ReplyType == oneway_void ->
%% no reply for oneway void
{State, ok}
end.
这里我只是检查函数是否定义为
单向无效
如果这是真的,我仍然收到一个不同于原子的返回值
ok
这就是开发人员在更新后的
handle_success
=ERROR REPORT==== 7-Sep-2010::11:06:43 ===
oneway void secret_function sent reply which must be ignored: {{ok,
<0.262.0>},
[]}
这至少能救你一次命(同上)。