From e1a7998837787ef4065337cb326586dc6a3cd0bf Mon Sep 17 00:00:00 2001 From: David Reiss Date: Tue, 10 Jun 2008 22:58:14 +0000 Subject: [PATCH] Fix responses for void functions git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666382 13f79535-47bb-0310-9956-ffa450edef68 --- lib/alterl/src/thrift_processor.erl | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) 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. -- 2.17.1