Return-Path: X-Original-To: apmail-avro-commits-archive@www.apache.org Delivered-To: apmail-avro-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EE79DE2FF for ; Wed, 28 Nov 2012 22:47:29 +0000 (UTC) Received: (qmail 52338 invoked by uid 500); 28 Nov 2012 22:47:29 -0000 Delivered-To: apmail-avro-commits-archive@avro.apache.org Received: (qmail 52311 invoked by uid 500); 28 Nov 2012 22:47:29 -0000 Mailing-List: contact commits-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list commits@avro.apache.org Received: (qmail 52303 invoked by uid 99); 28 Nov 2012 22:47:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2012 22:47:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2012 22:47:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9D3132388A4A; Wed, 28 Nov 2012 22:47:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1414979 - in /avro/trunk: CHANGES.txt lang/ruby/lib/avro/ipc.rb Date: Wed, 28 Nov 2012 22:47:06 -0000 To: commits@avro.apache.org From: cutting@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121128224706.9D3132388A4A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cutting Date: Wed Nov 28 22:47:05 2012 New Revision: 1414979 URL: http://svn.apache.org/viewvc?rev=1414979&view=rev Log: AVRO-1177. Ruby: Fix RPC to only send handshake for first request over a connection. Contributed by Georg Franz. Modified: avro/trunk/CHANGES.txt avro/trunk/lang/ruby/lib/avro/ipc.rb Modified: avro/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1414979&r1=1414978&r2=1414979&view=diff ============================================================================== --- avro/trunk/CHANGES.txt (original) +++ avro/trunk/CHANGES.txt Wed Nov 28 22:47:05 2012 @@ -66,6 +66,9 @@ Trunk (not yet released) AVRO-1206. Ruby: Fix UTF-8 handling in Ruby 1.9. (Nicolas Fouché via cutting) + AVRO-1177. Ruby: Fix RPC to only send handshake for first request + over a connection. (Georg Franz via cutting) + Avro 1.7.2 (20 October 2012) NEW FEATURES Modified: avro/trunk/lang/ruby/lib/avro/ipc.rb URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/lib/avro/ipc.rb?rev=1414979&r1=1414978&r2=1414979&view=diff ============================================================================== --- avro/trunk/lang/ruby/lib/avro/ipc.rb (original) +++ avro/trunk/lang/ruby/lib/avro/ipc.rb Wed Nov 28 22:47:05 2012 @@ -242,7 +242,7 @@ module Avro::IPC # Called by a server to deserialize a request, compute and serialize # a response or error. Compare to 'handle()' in Thrift. - def respond(call_request) + def respond(call_request, transport=nil) buffer_decoder = Avro::IO::BinaryDecoder.new(StringIO.new(call_request)) buffer_writer = StringIO.new('', 'w+') buffer_encoder = Avro::IO::BinaryEncoder.new(buffer_writer) @@ -250,7 +250,7 @@ module Avro::IPC response_metadata = {} begin - remote_protocol = process_handshake(buffer_decoder, buffer_encoder) + remote_protocol = process_handshake(buffer_decoder, buffer_encoder, transport) # handshake failure unless remote_protocol return buffer_writer.string @@ -302,7 +302,10 @@ module Avro::IPC buffer_writer.string end - def process_handshake(decoder, encoder) + def process_handshake(decoder, encoder, connection=nil) + if connection && connection.is_connected? + return connection.protocol + end handshake_request = HANDSHAKE_RESPONDER_READER.read(decoder) handshake_response = {} @@ -338,6 +341,11 @@ module Avro::IPC end HANDSHAKE_RESPONDER_WRITER.write(handshake_response, encoder) + + if connection && handshake_response['match'] != 'NONE' + connection.protocol = remote_protocol + end + remote_protocol end @@ -366,9 +374,15 @@ module Avro::IPC # A simple socket-based Transport implementation. attr_reader :sock, :remote_name + attr_accessor :protocol def initialize(sock) @sock = sock + @protocol = nil + end + + def is_connected?() + !!@protocol end def transceive(request)