THRIFT-660. php: Use the accelerator to write return values from servers
authorDavid Reiss <dreiss@apache.org>
Tue, 9 Mar 2010 05:19:22 +0000 (05:19 +0000)
committerDavid Reiss <dreiss@apache.org>
Tue, 9 Mar 2010 05:19:22 +0000 (05:19 +0000)
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

compiler/cpp/src/generate/t_php_generator.cc

index 38a63fa..3532eb0 100644 (file)
@@ -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_ <<