From: David Reiss Date: Tue, 10 Jun 2008 22:58:14 +0000 (+0000) Subject: Fix responses for void functions X-Git-Tag: 0.2.0~762 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=e1a7998837787ef4065337cb326586dc6a3cd0bf;p=common%2Fthrift.git Fix responses for void functions git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666382 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/alterl/src/thrift_processor.erl b/lib/alterl/src/thrift_processor.erl index c193946b..14724aa7 100644 --- a/lib/alterl/src/thrift_processor.erl +++ b/lib/alterl/src/thrift_processor.erl @@ -51,15 +51,24 @@ handle_function(State = #state{in_protocol = IProto, [Function, Params, Micro/1000.0]), ReplyType = Service:function_info(Function, reply_type), + StructName = atom_to_list(Function) ++ "_result", case Result of - {reply, Reply} -> - StructName = atom_to_list(Function) ++ "_result", - thrift_protocol:write(OProto, #protocol_message_begin{ - name = StructName, - type = ?tMessageType_REPLY, - seqid = 0}), - thrift_protocol:write(OProto, {{struct, [{0, ReplyType}]}, {StructName, Reply}}), - thrift_protocol:write(OProto, message_end) + {reply, ReplyData} -> + Reply = {{struct, [{0, ReplyType}]}, {StructName, ReplyData}}, + ok = send_reply(OProto, Function, Reply); + + ok when ReplyType == {struct, []} -> + ok = send_reply(OProto, Function, {ReplyType, {StructName}}) end, ok. + + +send_reply(OProto, Function, Reply) -> + ok = thrift_protocol:write(OProto, #protocol_message_begin{ + name = atom_to_list(Function), + type = ?tMessageType_REPLY, + seqid = 0}), + ok = thrift_protocol:write(OProto, Reply), + ok = thrift_protocol:write(OProto, message_end), + ok.