Author: dreiss
Date: Tue Mar  9 05:19:22 2010
New Revision: 920663

URL: http://svn.apache.org/viewvc?rev=920663&view=rev
Log:
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.

Modified:
    incubator/thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc?rev=920663&r1=920662&r2=920663&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc 
(original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc Tue Mar 
 9 05:19:22 2010
@@ -1134,6 +1134,21 @@ void t_php_generator::generate_process_f
     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_f
       indent() << "$output->getTransport()->flush();" << endl;
   }
 
+  scope_down(f_service_);
+
   // Close function
   indent_down();
   f_service_ <<


Reply via email to