From: David Reiss Date: Tue, 9 Mar 2010 05:19:22 +0000 (+0000) Subject: THRIFT-660. php: Use the accelerator to write return values from servers X-Git-Tag: 0.3.0~96 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=e574a065a9ed100bda718582dc3378abc2933e78;p=common%2Fthrift.git THRIFT-660. php: Use the accelerator to write return values from servers Previously, we only used the acclerator module for clients to write calls and read returns. Now PHP servers will use it for writing returns. We cannot use it to read calls on the server side (without modifications), because the module requires that the structure type be known before reading the message header. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920663 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc index 38a63faa..3532eb09 100644 --- a/compiler/cpp/src/generate/t_php_generator.cc +++ b/compiler/cpp/src/generate/t_php_generator.cc @@ -1134,6 +1134,21 @@ void t_php_generator::generate_process_function(t_service* tservice, return; } + f_service_ << + indent() << "$bin_accel = ($output instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary');" << endl; + + f_service_ << + indent() << "if ($bin_accel)" << endl; + scope_up(f_service_); + + f_service_ << + indent() << "thrift_protocol_write_binary($output, '" << tfunction->get_name() << "', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite());" << endl; + + scope_down(f_service_); + f_service_ << + indent() << "else" << endl; + scope_up(f_service_); + // Serialize the request header if (binary_inline_) { f_service_ << @@ -1151,6 +1166,8 @@ void t_php_generator::generate_process_function(t_service* tservice, indent() << "$output->getTransport()->flush();" << endl; } + scope_down(f_service_); + // Close function indent_down(); f_service_ <<