You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2015/06/18 16:03:08 UTC
[01/50] qpid-proton git commit: PROTON-334: Add capability to detect
extended SASL support
Repository: qpid-proton
Updated Branches:
refs/heads/PROTON-781-ruby-reactor-apis f63454c5c -> 534c3410c (forced update)
PROTON-334: Add capability to detect extended SASL support
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d7df5760
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d7df5760
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d7df5760
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: d7df5760f979a2e0503b272638067493fd5b9e7b
Parents: 7346d23
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Jun 11 13:53:04 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Jun 11 16:19:54 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 4 ++++
proton-c/include/proton/sasl.h | 13 +++++++++++++
proton-c/src/sasl/cyrus_sasl.c | 5 +++++
proton-c/src/sasl/none_sasl.c | 5 +++++
proton-j/src/main/resources/csasl.py | 3 +++
5 files changed, 30 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d7df5760/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index e3cd9e3..9432bd8 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -3368,6 +3368,10 @@ class SASL(Wrapper):
PERM = PN_SASL_PERM
TEMP = PN_SASL_TEMP
+ @staticmethod
+ def extended():
+ return pn_sasl_extended()
+
def __init__(self, transport):
Wrapper.__init__(self, transport._impl, pn_transport_attachments)
self._sasl = pn_sasl(transport._impl)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d7df5760/proton-c/include/proton/sasl.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/sasl.h b/proton-c/include/proton/sasl.h
index b2a8a27..60ee7d5 100644
--- a/proton-c/include/proton/sasl.h
+++ b/proton-c/include/proton/sasl.h
@@ -68,6 +68,19 @@ typedef enum {
*/
PN_EXTERN pn_sasl_t *pn_sasl(pn_transport_t *transport);
+/** Do we support extended SASL negotiation
+ *
+ * Do we support extended SASL negotiation?
+ * All implementations of Proton support ANONYMOUS and EXTERNAL on both
+ * client and server sides and PLAIN on the client side.
+ *
+ * Extended SASL implememtations use an external library (Cyrus SASL)
+ * to support other mechanisms beyond these basic ones.
+ *
+ * @return true if we support extended SASL negotiation, false if we only support basic negotiation.
+ */
+PN_EXTERN bool pn_sasl_extended(void);
+
/** Set the outcome of SASL negotiation
*
* Used by the server to set the result of the negotiation process.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d7df5760/proton-c/src/sasl/cyrus_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c
index 31703a8..b42ffa5 100644
--- a/proton-c/src/sasl/cyrus_sasl.c
+++ b/proton-c/src/sasl/cyrus_sasl.c
@@ -380,3 +380,8 @@ void pni_sasl_impl_free(pn_transport_t *transport)
sasl_server_done();
}
}
+
+bool pn_sasl_extended(void)
+{
+ return true;
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d7df5760/proton-c/src/sasl/none_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/none_sasl.c b/proton-c/src/sasl/none_sasl.c
index 4a2dc13..be27871 100644
--- a/proton-c/src/sasl/none_sasl.c
+++ b/proton-c/src/sasl/none_sasl.c
@@ -171,3 +171,8 @@ void pni_process_challenge(pn_transport_t *transport, const pn_bytes_t *recv)
void pni_process_response(pn_transport_t *transport, const pn_bytes_t *recv)
{
}
+
+bool pn_sasl_extended(void)
+{
+ return false;
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d7df5760/proton-j/src/main/resources/csasl.py
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/csasl.py b/proton-j/src/main/resources/csasl.py
index ea5e489..32f8039 100644
--- a/proton-j/src/main/resources/csasl.py
+++ b/proton-j/src/main/resources/csasl.py
@@ -30,6 +30,9 @@ PN_SASL_SYS=2
PN_SASL_PERM=3
PN_SASL_TEMP=4
+def pn_sasl_extended():
+ return False
+
def pn_sasl(tp):
sasl = tp.impl.sasl()
if tp.server:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[36/50] qpid-proton git commit: PROTON-781: Added the Reactor class
to the Ruby reactor APIs.
Posted by mc...@apache.org.
PROTON-781: Added the Reactor class to the Ruby reactor APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/83e923bc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/83e923bc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/83e923bc
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 83e923bc2359ec566834df0be452bf8c7b5a0deb
Parents: 1c30260
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon Feb 23 16:21:02 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/reactor/reactor.rb | 198 +++++++++++++++++++++
2 files changed, 199 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/83e923bc/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index bffd4d1..f8703e7 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -95,6 +95,7 @@ require "handler/messaging_handler"
# Reactor classes
require "reactor/task"
require "reactor/acceptor"
+require "reactor/reactor"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/83e923bc/proton-c/bindings/ruby/lib/reactor/reactor.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/reactor.rb b/proton-c/bindings/ruby/lib/reactor/reactor.rb
new file mode 100644
index 0000000..1cf4f6c
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/reactor.rb
@@ -0,0 +1,198 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class Reactor
+
+ include Qpid::Proton::Util::Handler
+
+ # @private
+ include Qpid::Proton::Util::SwigHelper
+
+ # @private
+ PROTON_METHOD_PREFIX = "pn_reactor"
+
+ proton_caller :yield
+
+ proton_caller :mark
+
+ proton_caller :start
+
+ proton_caller :stop
+
+ # @private
+ include Qpid::Proton::Util::Timeout
+
+ include Qpid::Proton::Util::Wrapper
+
+ attr_reader :errors
+
+ def self.wrap(impl)
+ return nil if impl.nil?
+
+ self.fetch_instance(impl, :pn_reactor_attachments) || Reactor.new(nil, :impl => impl)
+ end
+
+ def initialize(handlers, options = {})
+ @impl = options[:impl]
+ if @impl.nil?
+ @impl = Cproton.pn_reactor
+ end
+ if !handlers.nil?
+ [handlers].flatten.each {|handler| self.handler.add(handler)}
+ end
+ @errors = []
+ @handlers = []
+ self.class.store_instance(self, :pn_reactor_attachments)
+ end
+
+ # Returns whether the reactor has any unbuffered data.
+ #
+ # @return [Boolean] True if there is no unbuffered data.
+ #
+ def quiesced?
+ Cproton.pn_reactor_quiesced(@impl)
+ end
+
+ def on_error(info)
+ self.errors << info
+ self.yield
+ end
+
+ def global_handler
+ impl = Cproton.pn_reactor_get_global_handler(@impl)
+ Qpid::Proton::Handler::WrappedHandler.wrap(impl, self.method(:on_error))
+ end
+
+ def global_handler=(handler)
+ impl = chandler(handler, self.method(:on_error))
+ Cproton.pn_reactor_set_global_handler(@impl, impl)
+ Cproton.pn_decref(impl)
+ end
+
+ # Returns the timeout period.
+ #
+ # @return [Fixnum] The timeout period, in seconds.
+ #
+ def timeout
+ millis_to_timeout(Cproton.pn_reactor_get_timeout(@impl))
+ end
+
+ # Sets the timeout period.
+ #
+ # @param timeout [Fixnum] The timeout, in seconds.
+ #
+ def timeout=(timeout)
+ Cproton.pn_reactor_set_timeout(@impl, timeout_to_millis(timeout))
+ end
+
+ def handler
+ impl = Cproton.pn_reactor_get_handler(@impl)
+ Qpid::Proton::Handler::WrappedHandler.wrap(impl, self.method(:on_error))
+ end
+
+ def handler=(handler)
+ impl = chandler(handler, set.method(:on_error))
+ Cproton.pn_reactor_set_handler(@impl, impl)
+ Cproton.pn_decref(impl)
+ end
+
+ def run(&block)
+ self.timeout = 3.14159265359
+ self.start
+ while self.process do
+ if block_given?
+ yield
+ end
+ end
+ self.stop
+ end
+
+ def wakeup
+ n = Cproton.pn_reactor_wakeup(@impl)
+ unless n.zero?
+ io = Cproton.pn_reactor_io(@impl)
+ raise IOError.new(Cproton.pn_io_error(io))
+ end
+ end
+
+ def process
+ result = Cproton.pn_reactor_process(@impl)
+ if !self.errors.nil? && !self.errors.empty?
+ (0...self.errors.size).each do |index|
+ error_set = self.errors[index]
+ print error.backtrace.join("\n")
+ end
+ raise self.errors.last
+ end
+ return result
+ end
+
+ def schedule(delay, task)
+ impl = chandler(task, self.method(:on_error))
+ task = Task.wrap(Cproton.pn_reactor_schedule(@impl, sec_to_millis(delay), impl))
+ Cproton.pn_decref(impl)
+ return task
+ end
+
+ def acceptor(host, port, handler = nil)
+ impl = chandler(handler, self.method(:on_error))
+ aimpl = Cproton.pn_reactor_acceptor(@impl, host, "#{port}", impl)
+ Cproton.pn_decref(impl)
+ if !aimpl.nil?
+ return Acceptor.new(aimpl)
+ else
+ io = Cproton.pn_reactor_io(@impl)
+ io_error = Cproton.pn_io_error(io)
+ error_text = Cproton.pn_error_text(io_error)
+ text = "(#{Cproton.pn_error_text(io_error)} (#{host}:#{port}))"
+ raise IOError.new(text)
+ end
+ end
+
+ def connection(handler = nil)
+ impl = chandler(handler, self.method(:on_error))
+ conn = Qpid::Proton::Connection.wrap(Cproton.pn_reactor_connection(@impl, impl))
+ Cproton.pn_decref(impl)
+ return conn
+ end
+
+ def selectable(handler = nil)
+ impl = chandler(handler, self.method(:on_error))
+ result = Selectable.wrap(Cproton.pn_reactor_selectable(@impl))
+ if !impl.nil?
+ record = Cproton.pn_selectable_attachments(result.impl)
+ Cproton.pn_record_set_handler(record, impl)
+ Cproton.pn_decref(impl)
+ end
+ return result
+ end
+
+ def update(sel)
+ Cproton.pn_reactor_update(@impl, sel.impl)
+ end
+
+ def push_event(obj, etype)
+ Cproton.pn_collector_put(Cproton.pn_reactor_collector(@impl), Qpid::Proton::Util::RBCTX, Cproton.pn_py2void(obj), etype.number)
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[22/50] qpid-proton git commit: PROTON-781: Added the Acking mixin to
the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added the Acking mixin to the Ruby reactive APIs.
The Acking mixin provides methods for handling the settling of messages
based on reactive callbacks.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8d8bfd23
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8d8bfd23
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8d8bfd23
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 8d8bfd23257a1b3944ec2793d40eddee0409d20e
Parents: 51e85ea
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Feb 25 13:27:30 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:19 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/handler/acking.rb | 70 +++++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 71 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8d8bfd23/proton-c/bindings/ruby/lib/handler/acking.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/acking.rb b/proton-c/bindings/ruby/lib/handler/acking.rb
new file mode 100644
index 0000000..2c94cfe
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/acking.rb
@@ -0,0 +1,70 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ # Mixing that provides methods for acknowledging a delivery.
+ #
+ module Acking
+
+ # Accept the receivered message.
+ #
+ # @param delivery [Qpid::Proton::Delivery] The delivery.
+ #
+ def accept(delivery)
+ self.settle(delivery, Qpid::Proton::Delivery::ACCEPTED)
+ end
+
+ # Rejects a received message that is considered invalid or unprocessable.
+ #
+ # @param delivery [Qpid::Proton::Delivery] The delivery.
+ #
+ def reject(delivery)
+ self.settle(delivery, Qpid::Proton::Delivery::REJECTED)
+ end
+
+ # Releases a received message, making it available at the source for any
+ # other interested receiver.
+ #
+ # @param delivery [Qpid::Proton::Delivery] The delivery
+ # @param delivered [Boolean] True if this was considered a delivery
+ # attempt.
+ #
+ def release(delivery, delivered = true)
+ if delivered
+ self.settle(delivery, Qpid::Proton::Delivery::MODIFIED)
+ else
+ self.settle(delivery, Qpid::Proton::Delivery::RELEASED)
+ end
+ end
+
+ # Settles the specified delivery. Updates the delivery state if a state
+ # is specified.
+ #
+ # @param delivery [Qpid::Proton::Delivery] The delivery.
+ # @param state [Fixnum] The delivery state.
+ #
+ def settle(delivery, state = nil)
+ delivery.update(state) unless state.nil?
+ delivery.settle
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8d8bfd23/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index a4b3391..8db28f3 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -84,6 +84,7 @@ require "messenger/messenger"
# Handler classes
require "handler/c_adaptor"
require "handler/wrapped_handler"
+require "handler/acking"
module Qpid::Proton
# @private
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[31/50] qpid-proton git commit: PROTON-781: Added
OutgoingMessageHandler to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added OutgoingMessageHandler to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/13789804
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/13789804
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/13789804
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 137898046f9089a873b1f3a0f9b7b504b494fa59
Parents: e165313
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Feb 26 09:59:18 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
.../lib/handler/outgoing_message_handler.rb | 98 ++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 99 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13789804/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
new file mode 100644
index 0000000..056a131
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
@@ -0,0 +1,98 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ # A utility for simpler and more intuitive handling of delivery events
+ # related to outgoing messages.
+ #
+ class OutgoingMessageHandler < Qpid::Proton::BaseHandler
+
+ def initialize(auto_settle = true, delegate = nil)
+ @auto_settle = auto_settle
+ @delegate = delegate
+ end
+
+ def on_link_flow(event)
+ self.on_sendable(event) if event.link.sender? && event.link.credit > 0
+ end
+
+ def on_delivery(event)
+ delivery = event.delivery
+ if delivery.link.sender? && delivery.updated?
+ if delivery.remote_accepted?
+ self.on_accepted(event)
+ elsif delivery.remote_rejected?
+ self.on_rejected(event)
+ elsif delivery.remote_released? || delivery.remote_modified?
+ self.on_released(event)
+ end
+ self.on_settled(event) if delivery.settled?
+ delivery.settle if @auto_settle
+ end
+ end
+
+ # Called when the sender link has credit and messages and be transferred.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_sendable(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_sendable, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer accepts a sent message.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_accepted(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_accepted, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer rejects a sent message.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_rejected(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_rejected, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer releases an outgoing message.
+ #
+ # Note that this may be in resposnse to either the REELAASE or MODIFIED
+ # state as defined by the AMQP specification.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_released(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_released, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer has settled the outgoing message.
+ #
+ # This is the point at which it should never be retransmitted.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_settled(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil?
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13789804/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 1fbf710..5c2e1bc 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -88,6 +88,7 @@ require "handler/wrapped_handler"
require "handler/acking"
require "handler/endpoint_state_handler"
require "handler/incoming_message_handler"
+require "handler/outgoing_message_handler"
require "handler/c_flow_controller"
module Qpid::Proton
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[47/50] qpid-proton git commit: PROTON-781: Added support for
reactors to the Ruby Endpoint class.
Posted by mc...@apache.org.
PROTON-781: Added support for reactors to the Ruby Endpoint class.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e7213586
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e7213586
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e7213586
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: e72135860382c099a2a2f8838bb17c9e3d641c2a
Parents: 6598326
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Apr 16 10:41:08 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/endpoint.rb | 25 ++++++++++++++++++++++++
1 file changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e7213586/proton-c/bindings/ruby/lib/core/endpoint.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/endpoint.rb b/proton-c/bindings/ruby/lib/core/endpoint.rb
index cbf1015..f3ddbcb 100644
--- a/proton-c/bindings/ruby/lib/core/endpoint.rb
+++ b/proton-c/bindings/ruby/lib/core/endpoint.rb
@@ -110,6 +110,31 @@ module Qpid::Proton
!(self.state & state_mask).zero?
end
+ def handler
+ reactor = Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_object_reactor(@impl))
+ if reactor.nil?
+ on_error = nil
+ else
+ on_error = reactor.method(:on_error)
+ end
+ record = self.attachments
+ puts "record=#{record}"
+ WrappedHandler.wrap(Cproton.pn_record_get_handler(record), on_error)
+ end
+
+ def handler=(handler)
+ reactor = Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_object_reactor(@impl))
+ if reactor.nil?
+ on_error = nil
+ else
+ on_error = reactor.method(:on_error)
+ end
+ impl = chandler(handler, on_error)
+ record = self.attachments
+ Cproton.pn_record_set_handler(record, impl)
+ Cproton.pn_decref(impl)
+ end
+
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[20/50] qpid-proton git commit: PROTON-781: Deleted the Ruby Filter
mixin.
Posted by mc...@apache.org.
PROTON-781: Deleted the Ruby Filter mixin.
It was only used by Selectable, which is being refactored based on the
new underlying C Selectable type.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/00984cd9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/00984cd9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/00984cd9
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 00984cd9b587bc2b0c209f204448027766170a60
Parents: 1759776
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Tue Feb 24 10:55:25 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:19 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/messenger/filters.rb | 64 --------------------
.../bindings/ruby/lib/messenger/selectable.rb | 6 --
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 -
3 files changed, 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/00984cd9/proton-c/bindings/ruby/lib/messenger/filters.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/filters.rb b/proton-c/bindings/ruby/lib/messenger/filters.rb
deleted file mode 100644
index 0ab3407..0000000
--- a/proton-c/bindings/ruby/lib/messenger/filters.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Messenger
-
- # @private
- module Filters
-
- def self.included(base)
- base.class_eval do
- extend ClassMethods
- end
- end
-
- module ClassMethods
-
- def method_added(method_name)
- @@hooked_methods ||= []
- return if @@hooked_methods.include?(method_name)
- @@hooked_methods << method_name
- hooks = @@before_hooks[method_name]
- return if hooks.nil?
- orig_method = instance_method(method_name)
- define_method(method_name) do |*args, &block|
- hooks = @@before_hooks[method_name]
- hooks.each do |hook|
- method(hook).call
- end
-
- orig_method.bind(self).call(*args, &block)
- end
- end
-
- def call_before(before_method, *methods)
- @@before_hooks ||= {}
- methods.each do |method|
- hooks = @@before_hooks[method] || []
- raise "Repeat filter: #{before_method}" if hooks.include? before_method
- hooks << before_method
- @@before_hooks[method] = hooks
- end
- end
-
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/00984cd9/proton-c/bindings/ruby/lib/messenger/selectable.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/selectable.rb b/proton-c/bindings/ruby/lib/messenger/selectable.rb
index ec5174f..da1a3d5 100644
--- a/proton-c/bindings/ruby/lib/messenger/selectable.rb
+++ b/proton-c/bindings/ruby/lib/messenger/selectable.rb
@@ -25,12 +25,6 @@ module Qpid::Proton::Messenger
# @private
class Selectable
- include Filters
-
- call_before :check_is_initialized,
- :fileno, :capacity, :pending, :deadline,
- :readable, :writable, :expired,
- :registered=, :registered?
def initialize(messenger, impl) # :nodoc:
@messenger = messenger
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/00984cd9/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 2791538..21f96a1 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -75,7 +75,6 @@ require "core/ssl"
require "core/transport"
# Messenger API classes
-require "messenger/filters"
require "messenger/subscription"
require "messenger/tracker_status"
require "messenger/tracker"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[30/50] qpid-proton git commit: PROTON-781: Added the BaseHandler
class to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added the BaseHandler class to the Ruby reactive APIs.
This is the Ruby analog to the Handler class from Python. It needed to
be renamed, though, since it's in the Qpid::Proton namespace but would
collide with the Qpid::Proton::Handler namespace.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/afdef676
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/afdef676
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/afdef676
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: afdef6763bc98aa4a8098a8695d52dd42a85e974
Parents: e5299b2
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Feb 25 13:30:30 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/base_handler.rb | 31 ++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 32 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/afdef676/proton-c/bindings/ruby/lib/core/base_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/base_handler.rb b/proton-c/bindings/ruby/lib/core/base_handler.rb
new file mode 100644
index 0000000..9a7ece4
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/core/base_handler.rb
@@ -0,0 +1,31 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton
+
+ class BaseHandler
+
+ # Override to process unhandled events.
+ #
+ def on_unhandled(method, *args)
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/afdef676/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index e14ff9d..ef7f300 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -74,6 +74,7 @@ require "core/ssl_domain"
require "core/ssl_details"
require "core/ssl"
require "core/transport"
+require "core/base_handler"
# Messenger API classes
require "messenger/subscription"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[34/50] qpid-proton git commit: PROTON-781: Added Acceptor to the
Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added Acceptor to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1c302604
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1c302604
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1c302604
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 1c302604b97131a5ec375c887cd5e0c0436e9070
Parents: c690e56
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Fri Feb 27 10:14:57 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/reactor/acceptor.rb | 41 +++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1c302604/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index f3da844..bffd4d1 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -94,6 +94,7 @@ require "handler/messaging_handler"
# Reactor classes
require "reactor/task"
+require "reactor/acceptor"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1c302604/proton-c/bindings/ruby/lib/reactor/acceptor.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/acceptor.rb b/proton-c/bindings/ruby/lib/reactor/acceptor.rb
new file mode 100644
index 0000000..83e0596
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/acceptor.rb
@@ -0,0 +1,41 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class Acceptor
+
+ include Qpid::Proton::Util::Wrapper
+
+ def initialize(impl)
+ @impl = impl
+ self.class.store_instance(self)
+ end
+
+ def set_ssl_domain(ssl_domain)
+ Cproton.pn_acceptor_set_ssl_domain(@impl, ssl_domain.impl)
+ end
+
+ def close
+ Cproton.pn_acceptor_close(@impl)
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[19/50] qpid-proton git commit: PROTON-781: Repackaged the Ruby
Selectable class to Qpid::Proton.
Posted by mc...@apache.org.
PROTON-781: Repackaged the Ruby Selectable class to Qpid::Proton.
It's now a part of the core APIs and not part of the Messenger APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9454f507
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9454f507
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9454f507
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 9454f507ac442bb5932040b41193158e1cb1718c
Parents: 00984cd
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Tue Feb 24 13:31:51 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:19 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/selectable.rb | 118 +++++++++++++++++++
.../bindings/ruby/lib/messenger/selectable.rb | 118 -------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 2 +-
3 files changed, 119 insertions(+), 119 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9454f507/proton-c/bindings/ruby/lib/core/selectable.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/selectable.rb b/proton-c/bindings/ruby/lib/core/selectable.rb
new file mode 100644
index 0000000..8a5b223
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/core/selectable.rb
@@ -0,0 +1,118 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton
+
+ # Selectable enables accessing the underlying file descriptors
+ # for Messenger.
+ #
+ # @private
+ class Selectable
+
+
+ def initialize(messenger, impl) # :nodoc:
+ @messenger = messenger
+ @impl = impl
+ @io = nil
+ @freed = false
+ end
+
+ # Returns the underlying file descriptor.
+ #
+ # This can be used in conjunction with the IO class.
+ #
+ def fileno
+ Cproton.pn_selectable_get_fd(@impl)
+ end
+
+ def to_io
+ @io ||= IO.new(fileno)
+ end
+
+ # The number of bytes the selectable is capable of consuming.
+ #
+ #def capacity
+ # Cproton.pn_selectable_capacity(@impl)
+ #end
+
+ # The number of bytes waiting to be written to the file descriptor.
+ #
+ def pending
+ Cproton.pn_selectable_pending(@impl)
+ end
+
+ # The future expiry time at which control will be returned to the
+ # selectable.
+ #
+ def deadline
+ tstamp = Cproton.pn_selectable_deadline(@impl)
+ tstamp.nil? ? nil : tstamp / 1000
+ end
+
+ def readable
+ Cproton.pn_selectable_readable(@impl)
+ end
+
+ def writable
+ Cproton.pn_selectable_writable(@impl)
+ end
+
+ def expired?
+ Cproton.pn_selectable_expired(@impl)
+ end
+
+ def registered=(registered)
+ Cproton.pn_selectable_set_registered(@impl, registered)
+ end
+
+ def registered?
+ Cproton.pn_selectable_is_registered(@impl)
+ end
+
+ def terminal?
+ return true if @impl.nil?
+ Cproton.pn_selectable_is_terminal(@impl)
+ end
+
+ def to_s
+ "fileno=#{self.fileno} registered=#{self.registered?} terminal=#{self.terminal?}"
+ end
+
+ def free
+ return if @freed
+ @freed = true
+ @messenger.unregister_selectable(fileno)
+ @io.close unless @io.nil?
+ Cproton.pn_selectable_free(@impl)
+ @impl = nil
+ end
+
+ def freed? # :nodoc:
+ @freed
+ end
+
+ private
+
+ def check_is_initialized
+ raise RuntimeError.new("selectable freed") if @impl.nil?
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9454f507/proton-c/bindings/ruby/lib/messenger/selectable.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/selectable.rb b/proton-c/bindings/ruby/lib/messenger/selectable.rb
deleted file mode 100644
index da1a3d5..0000000
--- a/proton-c/bindings/ruby/lib/messenger/selectable.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Messenger
-
- # Selectable enables accessing the underlying file descriptors
- # for Messenger.
- #
- # @private
- class Selectable
-
-
- def initialize(messenger, impl) # :nodoc:
- @messenger = messenger
- @impl = impl
- @io = nil
- @freed = false
- end
-
- # Returns the underlying file descriptor.
- #
- # This can be used in conjunction with the IO class.
- #
- def fileno
- Cproton.pn_selectable_get_fd(@impl)
- end
-
- def to_io
- @io ||= IO.new(fileno)
- end
-
- # The number of bytes the selectable is capable of consuming.
- #
- #def capacity
- # Cproton.pn_selectable_capacity(@impl)
- #end
-
- # The number of bytes waiting to be written to the file descriptor.
- #
- def pending
- Cproton.pn_selectable_pending(@impl)
- end
-
- # The future expiry time at which control will be returned to the
- # selectable.
- #
- def deadline
- tstamp = Cproton.pn_selectable_deadline(@impl)
- tstamp.nil? ? nil : tstamp / 1000
- end
-
- def readable
- Cproton.pn_selectable_readable(@impl)
- end
-
- def writable
- Cproton.pn_selectable_writable(@impl)
- end
-
- def expired?
- Cproton.pn_selectable_expired(@impl)
- end
-
- def registered=(registered)
- Cproton.pn_selectable_set_registered(@impl, registered)
- end
-
- def registered?
- Cproton.pn_selectable_is_registered(@impl)
- end
-
- def terminal?
- return true if @impl.nil?
- Cproton.pn_selectable_is_terminal(@impl)
- end
-
- def to_s
- "fileno=#{self.fileno} registered=#{self.registered?} terminal=#{self.terminal?}"
- end
-
- def free
- return if @freed
- @freed = true
- @messenger.unregister_selectable(fileno)
- @io.close unless @io.nil?
- Cproton.pn_selectable_free(@impl)
- @impl = nil
- end
-
- def freed? # :nodoc:
- @freed
- end
-
- private
-
- def check_is_initialized
- raise RuntimeError.new("selectable freed") if @impl.nil?
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9454f507/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 21f96a1..a4b3391 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -58,6 +58,7 @@ require "event/event"
require "event/collector"
# Main Proton classes
+require "core/selectable"
require "core/message"
require "core/endpoint"
require "core/session"
@@ -78,7 +79,6 @@ require "core/transport"
require "messenger/subscription"
require "messenger/tracker_status"
require "messenger/tracker"
-require "messenger/selectable"
require "messenger/messenger"
# Handler classes
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[15/50] qpid-proton git commit: PROTON-915: Send correct AMQP header
upon protocol mismatch - Split apart the transport tests into client and
server tests
Posted by mc...@apache.org.
PROTON-915: Send correct AMQP header upon protocol mismatch
- Split apart the transport tests into client and server tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3aab9a07
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3aab9a07
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3aab9a07
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 3aab9a07bca507aa9160e00eb54179b3df441ebb
Parents: 638c18b
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Jun 17 15:44:29 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Jun 17 18:39:03 2015 -0400
----------------------------------------------------------------------
proton-c/src/transport/transport.c | 13 +-
tests/python/proton_tests/transport.py | 190 ++++++++++++++++++++++++++--
2 files changed, 191 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3aab9a07/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index 0e23975..733f695 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -168,6 +168,13 @@ const pn_io_layer_t pni_passthru_layer = {
NULL
};
+const pn_io_layer_t pni_header_error_layer = {
+ pn_io_layer_input_error,
+ pn_output_write_amqp_header,
+ NULL,
+ NULL
+};
+
const pn_io_layer_t pni_error_layer = {
pn_io_layer_input_error,
pn_io_layer_output_error,
@@ -286,7 +293,7 @@ ssize_t pn_io_layer_input_autodetect(pn_transport_t *transport, unsigned int lay
pn_do_error(transport, "amqp:connection:framing-error",
"%s: '%s'%s", error, quoted,
!eos ? "" : " (connection aborted)");
- pn_set_error_layer(transport);
+ transport->io_layers[layer] = &pni_header_error_layer;
return 0;
}
@@ -2397,7 +2404,9 @@ static ssize_t pn_output_write_amqp_header(pn_transport_t* transport, unsigned i
pn_transport_logf(transport, " -> %s", "AMQP");
assert(available >= 8);
memmove(bytes, AMQP_HEADER, 8);
- if (transport->io_layers[layer] == &amqp_write_header_layer) {
+ if (transport->io_layers[layer] == &pni_header_error_layer) {
+ transport->io_layers[layer] = &pni_error_layer;
+ }else if (transport->io_layers[layer] == &amqp_write_header_layer) {
transport->io_layers[layer] = &amqp_layer;
} else {
transport->io_layers[layer] = &amqp_read_header_layer;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3aab9a07/tests/python/proton_tests/transport.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/transport.py b/tests/python/proton_tests/transport.py
index e56b122..958abf7 100644
--- a/tests/python/proton_tests/transport.py
+++ b/tests/python/proton_tests/transport.py
@@ -24,7 +24,7 @@ from proton import *
class Test(common.Test):
pass
-class TransportTest(Test):
+class ClientTransportTest(Test):
def setup(self):
self.transport = Transport()
@@ -87,6 +87,16 @@ class TransportTest(Test):
self.transport.close_tail()
self.assert_error(u'amqp:connection:framing-error')
+ def testProtocolNotSupported(self):
+ self.transport.push("AMQP\x01\x01\x0a\x00")
+ p = self.transport.pending()
+ assert p >= 8, p
+ bytes = self.transport.peek(p)
+ assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+ self.transport.pop(p)
+ self.drain()
+ assert self.transport.closed
+
def testPeek(self):
out = self.transport.peek(1024)
assert out is not None
@@ -163,30 +173,190 @@ class TransportTest(Test):
self.peer.push(dat2[len(dat1):])
self.peer.push(dat3)
+class ServerTransportTest(Test):
+
+ def setup(self):
+ self.transport = Transport(Transport.SERVER)
+ self.peer = Transport()
+ self.conn = Connection()
+ self.peer.bind(self.conn)
+
+ def teardown(self):
+ self.transport = None
+ self.peer = None
+ self.conn = None
+
+ def drain(self):
+ while True:
+ p = self.transport.pending()
+ if p < 0:
+ return
+ elif p > 0:
+ bytes = self.transport.peek(p)
+ self.peer.push(bytes)
+ self.transport.pop(len(bytes))
+ else:
+ assert False
+
+ def assert_error(self, name):
+ assert self.conn.remote_container is None, self.conn.remote_container
+ self.drain()
+ # verify that we received an open frame
+ assert self.conn.remote_container is not None, self.conn.remote_container
+ # verify that we received a close frame
+ assert self.conn.state == Endpoint.LOCAL_UNINIT | Endpoint.REMOTE_CLOSED, self.conn.state
+ # verify that a framing error was reported
+ assert self.conn.remote_condition.name == name, self.conn.remote_condition
+
+ # TODO: This may no longer be testing anything
+ def testEOS(self):
+ self.transport.push("") # should be a noop
+ self.transport.close_tail()
+ p = self.transport.pending()
+ self.drain()
+ assert self.transport.closed
+
+ def testPartial(self):
+ self.transport.push("AMQ") # partial header
+ self.transport.close_tail()
+ p = self.transport.pending()
+ assert p >= 8, p
+ bytes = self.transport.peek(p)
+ assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+ self.transport.pop(p)
+ self.drain()
+ assert self.transport.closed
+
+ def testGarbage(self, garbage="GARBAGE_"):
+ self.transport.push(garbage)
+ p = self.transport.pending()
+ assert p >= 8, p
+ bytes = self.transport.peek(p)
+ assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+ self.transport.pop(p)
+ self.drain()
+ assert self.transport.closed
+
+ def testSmallGarbage(self):
+ self.testGarbage("XXX")
+
+ def testBigGarbage(self):
+ self.testGarbage("GARBAGE_XXX")
+
+ def testHeader(self):
+ self.transport.push("AMQP\x00\x01\x00\x00")
+ self.transport.close_tail()
+ self.assert_error(u'amqp:connection:framing-error')
+
+ def testProtocolNotSupported(self):
+ self.transport.push("AMQP\x01\x01\x0a\x00")
+ p = self.transport.pending()
+ assert p >= 8, p
+ bytes = self.transport.peek(p)
+ assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+ self.transport.pop(p)
+ self.drain()
+ assert self.transport.closed
+
+ def testPeek(self):
+ out = self.transport.peek(1024)
+ assert out is not None
+
+ def testBindAfterOpen(self):
+ conn = Connection()
+ ssn = conn.session()
+ conn.open()
+ ssn.open()
+ conn.container = "test-container"
+ conn.hostname = "test-hostname"
+ trn = Transport()
+ trn.bind(conn)
+ out = trn.peek(1024)
+ assert "test-container" in out, repr(out)
+ assert "test-hostname" in out, repr(out)
+ self.transport.push(out)
+
+ c = Connection()
+ assert c.remote_container == None
+ assert c.remote_hostname == None
+ assert c.session_head(0) == None
+ self.transport.bind(c)
+ assert c.remote_container == "test-container"
+ assert c.remote_hostname == "test-hostname"
+ assert c.session_head(0) != None
+
+ def testCloseHead(self):
+ n = self.transport.pending()
+ assert n >= 0, n
+ try:
+ self.transport.close_head()
+ except TransportException, e:
+ assert "aborted" in str(e), str(e)
+ n = self.transport.pending()
+ assert n < 0, n
+
+ def testCloseTail(self):
+ n = self.transport.capacity()
+ assert n > 0, n
+ try:
+ self.transport.close_tail()
+ except TransportException, e:
+ assert "aborted" in str(e), str(e)
+ n = self.transport.capacity()
+ assert n < 0, n
+
+ def testUnpairedPop(self):
+ conn = Connection()
+ self.transport.bind(conn)
+
+ conn.hostname = "hostname"
+ conn.open()
+
+ dat1 = self.transport.peek(1024)
+
+ ssn = conn.session()
+ ssn.open()
+
+ dat2 = self.transport.peek(1024)
+
+ assert dat2[:len(dat1)] == dat1
+
+ snd = ssn.sender("sender")
+ snd.open()
+
+ self.transport.pop(len(dat1))
+ self.transport.pop(len(dat2) - len(dat1))
+ dat3 = self.transport.peek(1024)
+ self.transport.pop(len(dat3))
+ assert self.transport.peek(1024) == ""
+
+ self.peer.push(dat1)
+ self.peer.push(dat2[len(dat1):])
+ self.peer.push(dat3)
+
def testEOSAfterSASL(self):
- srv = Transport(mode=Transport.SERVER)
- srv.sasl().allowed_mechs('ANONYMOUS')
+ self.transport.sasl().allowed_mechs('ANONYMOUS')
self.peer.sasl().allowed_mechs('ANONYMOUS')
# this should send over the sasl header plus a sasl-init set up
# for anonymous
p = self.peer.pending()
- srv.push(self.peer.peek(p))
+ self.transport.push(self.peer.peek(p))
self.peer.pop(p)
# now we send EOS
- srv.close_tail()
+ self.transport.close_tail()
# the server may send an error back
- p = srv.pending()
+ p = self.transport.pending()
while p>0:
- self.peer.push(srv.peek(p))
- srv.pop(p)
- p = srv.pending()
+ self.peer.push(self.transport.peek(p))
+ self.transport.pop(p)
+ p = self.transport.pending()
# server closed
- assert srv.pending() < 0
+ assert self.transport.pending() < 0
class LogTest(Test):
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[49/50] qpid-proton git commit: PROTON-781: Added Container to the
Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added Container to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/6598326a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6598326a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6598326a
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 6598326a3774fd9153ed4ffb158dd1c537557027
Parents: e593ba8
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Feb 26 10:26:11 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/reactor/container.rb | 272 +++++++++++++++++++
2 files changed, 273 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6598326a/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index f40c608..ba1e66e 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -106,6 +106,7 @@ require "reactor/urls"
require "reactor/connector"
require "reactor/backoff"
require "reactor/session_per_connection"
+require "reactor/container"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6598326a/proton-c/bindings/ruby/lib/reactor/container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/container.rb b/proton-c/bindings/ruby/lib/reactor/container.rb
new file mode 100644
index 0000000..93b49bb
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -0,0 +1,272 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ # @private
+ class InternalTransactionHandler < Qpid::Proton::Handler::OutgoingMessageHandler
+
+ def initialize
+ super
+ end
+
+ def on_settled(event)
+ if event.delivery.respond_to? :transaction
+ event.transaction = event.delivery.transaction
+ event.delivery.transaction.handle_outcome(event)
+ end
+ end
+
+ end
+
+
+ # A representation of the AMQP concept of a container which, loosely
+ # speaking, is something that establishes links to or from another
+ # container on which messages are transferred.
+ #
+ # This is an extension to the Reactor classthat adds convenience methods
+ # for creating instances of Qpid::Proton::Connection, Qpid::Proton::Sender
+ # and Qpid::Proton::Receiver.
+ #
+ # @example
+ #
+ class Container < Reactor
+
+ include Qpid::Proton::Util::Reactor
+
+ include Qpid::Proton::Util::UUID
+
+ attr_accessor :container_id
+ attr_accessor :global_handler
+
+ def initialize(handlers, options = {})
+ super(handlers, options)
+
+ # only do the following if we're creating a new instance
+ if !options.has_key?(:impl)
+ @ssl = SSLConfig.new
+ if options[:global_handler]
+ self.global_handler = GlobalOverrides.new(options[:global_handler])
+ else
+ # very ugly, but using self.global_handler doesn't work in the constructor
+ ghandler = Reactor.instance_method(:global_handler).bind(self).call
+ ghandler = GlobalOverrides.new(ghandler)
+ Reactor.instance_method(:global_handler=).bind(self).call(ghandler)
+ end
+ @trigger = nil
+ @container_id = generate_uuid
+ end
+ end
+
+ # Initiates the establishment of an AMQP connection.
+ #
+ # @param options [Hash] A hash of named arguments.
+ #
+ def connect(options = {})
+ conn = self.connection(options[:handler])
+ conn.container = self.container_id || generate_uuid
+ connector = Connector.new(conn)
+ conn.overrides = connector
+ if !options[:url].nil?
+ connector.address = URLs.new([options[:url]])
+ elsif !options[:urls].nil?
+ connector.address = URLs.new(options[:urls])
+ elsif !options[:address].nil?
+ connector.address = URLs.new([Qpid::Proton::URL.new(options[:address])])
+ else
+ raise ArgumentError.new("either :url or :urls or :address required")
+ end
+
+ connector.heartbeat = options[:heartbeat] if !options[:heartbeat].nil?
+ if !options[:reconnect].nil?
+ connector.reconnect = options[:reconnect]
+ else
+ connector.reconnect = Backoff.new()
+ end
+
+ connector.ssl_domain = SessionPerConnection.new # TODO seems this should be configurable
+
+ conn.open
+
+ return conn
+ end
+
+ def _session(context)
+ if context.is_a?(Qpid::Proton::URL)
+ return self._session(self.connect(:url => context))
+ elsif context.is_a?(Qpid::Proton::Session)
+ return context
+ elsif context.is_a?(Qpid::Proton::Connection)
+ if context.session_policy?
+ return context.session_policy.session(context)
+ else
+ return self.create_session(context)
+ end
+ else
+ return context.session
+ end
+ end
+
+ # Initiates the establishment of a link over which messages can be sent.
+ #
+ # @param context [String, URL] The context.
+ # @param opts [Hash] Additional options.
+ # @param opts [String, Qpid::Proton::URL] The target address.
+ # @param opts [String] :source The source address.
+ # @param opts [Boolean] :dynamic
+ # @param opts [Object] :handler
+ # @param opts [Object] :tag_generator The tag generator.
+ # @param opts [Hash] :options Addtional link options
+ #
+ # @return [Sender] The sender.
+ #
+ def create_sender(context, opts = {})
+ if context.is_a?(::String)
+ context = Qpid::Proton::URL.new(context)
+ end
+
+ target = opts[:target]
+ if context.is_a?(Qpid::Proton::URL) && target.nil?
+ target = context.path
+ end
+
+ session = self._session(context)
+
+ sender = session.sender(opts[:name] ||
+ id(session.connection.container,
+ target, opts[:source]))
+ sender.source.address = opts[:source] if !opts[:source].nil?
+ sender.target.address = target if target
+ sender.handler = opts[:handler] if !opts[:handler].nil?
+ sender.tag_generator = opts[:tag_generator] if !opts[:tag_gnenerator].nil?
+ self._apply_link_options(opts[:options], sender)
+ sender.open
+ return sender
+ end
+
+ # Initiates the establishment of a link over which messages can be received.
+ #
+ # There are two accepted arguments for the context
+ # 1. If a Connection is supplied then the link is established using that
+ # object. The source, and optionally the target, address can be supplied
+ # 2. If it is a String or a URL then a new Connection is created on which
+ # the link will be attached. If a path is specified, but not the source
+ # address, then the path of the URL is used as the target address.
+ #
+ # The name will be generated for the link if one is not specified.
+ #
+ # @param context [Connection, URL, String] The connection or the address.
+ # @param opts [Hash] Additional otpions.
+ # @option opts [String, Qpid::Proton::URL] The source address.
+ # @option opts [String] :target The target address
+ # @option opts [String] :name The link name.
+ # @option opts [Boolean] :dynamic
+ # @option opts [Object] :handler
+ # @option opts [Hash] :options Additional link options.
+ #
+ # @return [Receiver
+ #
+ def create_receiver(context, opts = {})
+ if context.is_a?(::String)
+ context = Qpid::Proton::URL.new(context)
+ end
+
+ source = opts[:source]
+ if context.is_a?(Qpid::Proton::URL) && source.nil?
+ source = context.path
+ end
+
+ session = self._session(context)
+
+ receiver = session.receiver(opts[:name] ||
+ id(session.connection.container,
+ source, opts[:target]))
+ receiver.source.address = source if source
+ receiver.source.dynamic = true if opts.has_key?(:dynamic) && opts[:dynamic]
+ receiver.target.address = opts[:target] if !opts[:target].nil?
+ receiver.handler = opts[:handler] if !opts[:handler].nil?
+ self._apply_link_options(opts[:options], receiver)
+ receiver.open
+ return receiver
+ end
+
+ def declare_transaction(context, handler = nil, settle_before_discharge = false)
+ if context.respond_to? :txn_ctl && !context.__send__(:txn_ctl).nil?
+ class << context
+ attr_accessor :txn_ctl
+ end
+ context.txn_ctl = self.create_sender(context, nil, "txn-ctl",
+ InternalTransactionHandler.new())
+ end
+ return Transaction.new(context.txn_ctl, handler, settle_before_discharge)
+ end
+
+ # Initiates a server socket, accepting incoming AMQP connections on the
+ # interface and port specified.
+ #
+ # @param url []
+ # @param ssl_domain []
+ #
+ def listen(url, ssl_domain = nil)
+ url = Qpid::Proton::URL.new(url)
+ acceptor = self.acceptor(url.host, url.port)
+ ssl_config = ssl_domain
+ if ssl_config.nil? && (url.scheme == 'amqps') && @ssl
+ ssl_config = @ssl.server
+ end
+ if !ssl_config.nil?
+ acceptor.ssl_domain(ssl_config)
+ end
+ return acceptor
+ end
+
+ def do_work(timeout = nil)
+ self.timeout = timeout unless timeout.nil?
+ self.process
+ end
+
+ def id(container, remote, local)
+ if !local.nil? && !remote.nil?
+ "#{container}-#{remote}-#{local}"
+ elsif !local.nil?
+ "#{container}-#{local}"
+ elsif !remote.nil?
+ "#{container}-#{remote}"
+ else
+ "#{container}-#{generate_uuid}"
+ end
+ end
+
+ def _apply_link_options(options, link)
+ if !options.nil? && !options.empty?
+ if !options.is_a?(::List)
+ options = [Options].flatten
+ end
+
+ options.each {|option| o.apply(link) if o.test(link)}
+ end
+ end
+
+ def to_s
+ "#{self.class}<@impl=#{Cproton.pni_address_of(@impl)}>"
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[07/50] qpid-proton git commit: PROTON-887: SChannel version of
pn_ssl_get_remote_subject()
Posted by mc...@apache.org.
PROTON-887: SChannel version of pn_ssl_get_remote_subject()
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2117b3b6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2117b3b6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2117b3b6
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 2117b3b6d9ebd1e6a157c437017f0456dc13a2f3
Parents: c2c178c
Author: Clifford Jansen <cl...@apache.org>
Authored: Tue Jun 16 07:42:42 2015 -0700
Committer: Clifford Jansen <cl...@apache.org>
Committed: Tue Jun 16 07:42:42 2015 -0700
----------------------------------------------------------------------
proton-c/src/windows/schannel.c | 53 ++++++++++++++++++++++++++++--------
1 file changed, 42 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2117b3b6/proton-c/src/windows/schannel.c
----------------------------------------------------------------------
diff --git a/proton-c/src/windows/schannel.c b/proton-c/src/windows/schannel.c
index 757a108..28550fb 100644
--- a/proton-c/src/windows/schannel.c
+++ b/proton-c/src/windows/schannel.c
@@ -283,6 +283,7 @@ struct pni_ssl_t {
SecPkgContext_StreamSizes sc_sizes;
pn_ssl_verify_mode_t verify_mode;
win_credential_t *cred;
+ char *subject;
};
static inline pn_transport_t *get_transport_internal(pn_ssl_t *ssl)
@@ -728,6 +729,7 @@ void pn_ssl_free( pn_transport_t *transport)
if (ssl->sc_inbuf) free((void *)ssl->sc_inbuf);
if (ssl->sc_outbuf) free((void *)ssl->sc_outbuf);
if (ssl->inbuf2) pn_buffer_free(ssl->inbuf2);
+ if (ssl->subject) free(ssl->subject);
free(ssl);
}
@@ -811,10 +813,39 @@ int pn_ssl_get_peer_hostname( pn_ssl_t *ssl0, char *hostname, size_t *bufsize )
return 0;
}
-const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl)
+const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl0)
{
- //TODO: actual implementation
- return NULL;
+ // RFC 2253 compliant, but differs from openssl's subject string with space separators and
+ // ordering of multicomponent RDNs. Made to work as similarly as possible with choice of flags.
+ pni_ssl_t *ssl = get_ssl_internal(ssl0);
+ if (!ssl || !SecIsValidHandle(&ssl->ctxt_handle))
+ return NULL;
+ if (!ssl->subject) {
+ SECURITY_STATUS status;
+ PCCERT_CONTEXT peer_cc = 0;
+ status = QueryContextAttributes(&ssl->ctxt_handle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &peer_cc);
+ if (status != SEC_E_OK) {
+ ssl_log_error_status(status, "can't obtain remote certificate subject");
+ return NULL;
+ }
+ DWORD flags = CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG;
+ DWORD strlen = CertNameToStr(peer_cc->dwCertEncodingType, &peer_cc->pCertInfo->Subject,
+ flags, NULL, 0);
+ if (strlen > 0) {
+ ssl->subject = (char*) malloc(strlen);
+ if (ssl->subject) {
+ DWORD len = CertNameToStr(peer_cc->dwCertEncodingType, &peer_cc->pCertInfo->Subject,
+ flags, ssl->subject, strlen);
+ if (len != strlen) {
+ free(ssl->subject);
+ ssl->subject = NULL;
+ ssl_log_error("pn_ssl_get_remote_subject failure in CertNameToStr");
+ }
+ }
+ }
+ CertFreeCertificateContext(peer_cc);
+ }
+ return ssl->subject;
}
@@ -1678,16 +1709,16 @@ static ssize_t process_output_ssl( pn_transport_t *transport, unsigned int layer
if (ssl->network_out_pending == 0) {
if (ssl->state == SHUTTING_DOWN) {
- if (!ssl->queued_shutdown) {
- start_ssl_shutdown(transport);
- work_pending = true;
- } else {
- ssl->state = SSL_CLOSED;
- }
+ if (!ssl->queued_shutdown) {
+ start_ssl_shutdown(transport);
+ work_pending = true;
+ } else {
+ ssl->state = SSL_CLOSED;
+ }
}
else if (ssl->state == NEGOTIATING && ssl->app_input_closed) {
- ssl->app_output_closed = PN_EOS;
- ssl->state = SSL_CLOSED;
+ ssl->app_output_closed = PN_EOS;
+ ssl->state = SSL_CLOSED;
}
}
} while (work_pending);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[08/50] qpid-proton git commit: PROTON-895: missing errno import
Posted by mc...@apache.org.
PROTON-895: missing errno import
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/821b4e1e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/821b4e1e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/821b4e1e
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 821b4e1e96b0d449a925272e4fad713f9d42485b
Parents: 2117b3b
Author: Flavio Percoco <fl...@gmail.com>
Authored: Tue Jun 16 09:37:16 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Tue Jun 16 12:05:46 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/python/setuputils/misc.py | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/821b4e1e/proton-c/bindings/python/setuputils/misc.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/misc.py b/proton-c/bindings/python/setuputils/misc.py
index cf6b97f..3a32165 100644
--- a/proton-c/bindings/python/setuputils/misc.py
+++ b/proton-c/bindings/python/setuputils/misc.py
@@ -12,6 +12,7 @@
#-----------------------------------------------------------------------------
+import errno
import os
import subprocess
import sys
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[28/50] qpid-proton git commit: PROTON-781: Added
EndpointStateHandler to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added EndpointStateHandler to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/132e2a3b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/132e2a3b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/132e2a3b
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 132e2a3b92258b9dbd14b27e38692a28369b52b7
Parents: 8d8bfd2
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Feb 25 13:28:38 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
.../ruby/lib/handler/endpoint_state_handler.rb | 217 +++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 218 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132e2a3b/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb b/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb
new file mode 100644
index 0000000..727a20b
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb
@@ -0,0 +1,217 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ # A utility that exposes endpoint events; i.e., the open/close of a link,
+ # session or connection, in a more intuitive manner.
+ #
+ # A XXX_opened method will be called when both local and remote peers have
+ # opened the link, session or connection. This can be used to confirm a
+ # locally initiated action for example.
+ #
+ # A XXX_opening method will be called when the remote peer has requested
+ # an open that was not initiated locally. By default this will simply open
+ # locally, which then trigtgers the XXX_opened called.
+ #
+ # The same applies to close.
+ #
+ class EndpointStateHandler < Qpid::Proton::BaseHandler
+
+ def initialize(peer_close_is_error = false, delegate = nil)
+ @delegate = delegate
+ @peer_close_is_error = peer_close_is_error
+ end
+
+ def self.print_error(endpoint, endpoint_type)
+ if !endpoint.remote_condition.nil?
+ elsif self.local_endpoint?(endpoint) && endpoint.remote_closed?
+ logging.error("#{endpoint_type} closed by peer")
+ end
+ end
+
+ def on_link_remote_close(event)
+ if !event.link.remote_condition.nil?
+ self.on_link_error(event)
+ elsif event.link.local_closed?
+ self.on_link_closed(event)
+ else
+ self.on_link_closing(event)
+ end
+ event.link.close
+ end
+
+ def on_session_remote_close(event)
+ if !event.session.remote_condition.nil?
+ self.on_session_error(event)
+ elsif event.session.local_closed?
+ self.on_session_closed(event)
+ else
+ self.on_session_closing(event)
+ end
+ event.session.close
+ end
+
+ def on_connection_remote_close(event)
+ if !event.connection.remote_condition.nil?
+ self.on_connection_error(event)
+ elsif event.connection.local_closed?
+ self.on_connection_closed(event)
+ else
+ self.on_connection_closing(event)
+ end
+ event.connection.close
+ end
+
+ def on_connection_local_open(event)
+ self.on_connection_opened(event) if event.connection.remote_active?
+ end
+
+ def on_connection_remote_open(event)
+ if !(event.connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
+ self.on_connection_opened(event)
+ elsif event.connection.local_uninit?
+ self.on_connection_opening(event)
+ event.connection.open
+ end
+ end
+
+ def on_session_local_open(event)
+ self.on_session_opened(event) if event.session.remote_active?
+ end
+
+ def on_session_remote_open(event)
+ if !(event.session.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
+ self.on_session_opened(event)
+ elsif event.session.local_uninit?
+ self.on_session_opening(event)
+ event.session.open
+ end
+ end
+
+ def on_link_local_open(event)
+ self.on_link_opened(event) if event.link.remote_active?
+ end
+
+ def on_link_remote_open(event)
+ if !(event.link.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
+ self.on_link_opened(event)
+ elsif event.link.local_uninit?
+ self.on_link_opening(event)
+ event.link.open
+ end
+ end
+
+ def on_connection_opened(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_session_opened, event) if !@delegate.nil?
+ end
+
+ def on_session_opened(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_session_opened, event) if !@delegate.nil?
+ end
+
+ def on_link_opened(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_link_opened, event) if !@delegate.nil?
+ end
+
+ def on_connection_opening(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_connection_opening, event) if !@delegate.nil?
+ end
+
+ def on_session_opening(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_session_opening, event) if !@delegate.nil?
+ end
+
+ def on_link_opening(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_link_opening, event) if !@delegate.nil?
+ end
+
+ def on_connection_error(event)
+ if !@delegate.nil?
+ Qpid::Proton::Event.dispatch(@delegate, :on_connection_error, event)
+ else
+ self.log_error(event.connection, "connection")
+ end
+ end
+
+ def on_session_error(event)
+ if !@delegate.nil?
+ Qpid::Proton::Event.dispatch(@delegate, :on_session_error, event)
+ else
+ self.log_error(event.session, "session")
+ event.connection.close
+ end
+ end
+
+ def on_link_error(event)
+ if !@delegate.nil?
+ Qpid::Proton::Event.dispatch(@delegate, :on_link_error, event)
+ else
+ self.log_error(event.link, "link")
+ event.conneciton.close
+ end
+ end
+
+ def on_connection_closed(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_connection_closed, event) if !@delegate.nil?
+ end
+
+ def on_session_closed(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_session_closed, event) if !@delegate.nil?
+ end
+
+ def on_link_closed(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_link_closed, event) if !@delegate.nil?
+ end
+
+ def on_connection_closing(event)
+ if !@delegate.nil?
+ Qpid::Proton::Event.dispatch(@delegate, :on_connection_closing, event)
+ elsif @peer_close_is_error
+ self.on_connection_error(event)
+ end
+ end
+
+ def on_session_closing(event)
+ if !@delegate.nil?
+ Qpid::Proton::Event.dispatch(@delegate, :on_session_closing, event)
+ elsif @peer_close_is_error
+ self.on_session_error(event)
+ end
+ end
+
+ def on_link_closing(event)
+ if !@delegate.nil?
+ Qpid::Proton::Event.dispatch(@delegate, :on_link_closing, event)
+ elsif @peer_close_is_error
+ self.on_link_error(event)
+ end
+ end
+
+ def on_transport_tail_closed(event)
+ self.on_transport_closed(event)
+ end
+
+ def on_transport_closed(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_disconnected, event) if !@delegate.nil?
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132e2a3b/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 8db28f3..08e60b9 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -85,6 +85,7 @@ require "messenger/messenger"
require "handler/c_adaptor"
require "handler/wrapped_handler"
require "handler/acking"
+require "handler/endpoint_state_handler"
module Qpid::Proton
# @private
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[04/50] qpid-proton git commit: PROTON-895: Let tox handle sdist and
install steps (patch from Flavio Percoco).
Posted by mc...@apache.org.
PROTON-895: Let tox handle sdist and install steps (patch from Flavio Percoco).
Since we're not using cmake anymore, we can let tox handle the sdist and
install steps so that everything happens within the tox venv.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f6e1948c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f6e1948c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f6e1948c
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: f6e1948c840e819ef264303b012aa450e2988f8a
Parents: 990b11e
Author: Gordon Sim <gs...@redhat.com>
Authored: Fri Jun 12 13:55:47 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Fri Jun 12 13:55:47 2015 +0100
----------------------------------------------------------------------
proton-c/bindings/python/tox.ini | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f6e1948c/proton-c/bindings/python/tox.ini
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/tox.ini b/proton-c/bindings/python/tox.ini
index aab5e4e..dddfe74 100644
--- a/proton-c/bindings/python/tox.ini
+++ b/proton-c/bindings/python/tox.ini
@@ -22,15 +22,11 @@ commands = python setup.py build_sphinx
[testenv:build]
usedevelop = False
-skipdist = True
-changedir = {toxinidir}
platform = linux2
-skip_install = True
setenv =
VIRTUAL_ENV={envdir}
PKG_CONFIG_PATH=None
QPID_PROTON_SRC={toxinidir}/../../../
DEBUG=True
commands =
- {envbindir}/python setup.py build -b {envbindir}/build install
{toxinidir}/../../../tests/python/proton-test {posargs}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[13/50] qpid-proton git commit: PROTON-916: copy SASL config name to
allow bindings to release the name
Posted by mc...@apache.org.
PROTON-916: copy SASL config name to allow bindings to release the name
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5b611b70
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5b611b70
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5b611b70
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 5b611b704441c508541b444300fbeb398ef61f80
Parents: 718d8b3
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Jun 17 15:01:55 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Jun 17 15:01:55 2015 -0400
----------------------------------------------------------------------
proton-c/src/sasl/sasl-internal.h | 2 +-
proton-c/src/sasl/sasl.c | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5b611b70/proton-c/src/sasl/sasl-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl-internal.h b/proton-c/src/sasl/sasl-internal.h
index 40df261..71205f5 100644
--- a/proton-c/src/sasl/sasl-internal.h
+++ b/proton-c/src/sasl/sasl-internal.h
@@ -61,7 +61,7 @@ struct pni_sasl_t {
char *included_mechanisms;
const char *username;
char *password;
- const char *config_name;
+ char *config_name;
char *config_dir;
const char *remote_fqdn;
char *external_auth;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5b611b70/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index c339ea9..47084ee 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -366,7 +366,7 @@ pn_sasl_t *pn_sasl(pn_transport_t *transport)
sasl->included_mechanisms = NULL;
sasl->username = NULL;
sasl->password = NULL;
- sasl->config_name = sasl->client ? "proton-client" : "proton-server";
+ sasl->config_name = pn_strdup(sasl->client ? "proton-client" : "proton-server");
sasl->config_dir = sasl_config_path ? pn_strdup(sasl_config_path) : NULL;
sasl->remote_fqdn = NULL;
sasl->external_auth = NULL;
@@ -455,7 +455,8 @@ void pn_sasl_allowed_mechs(pn_sasl_t *sasl0, const char *mechs)
void pn_sasl_config_name(pn_sasl_t *sasl0, const char *name)
{
pni_sasl_t *sasl = get_sasl_internal(sasl0);
- sasl->config_name = name;
+ free(sasl->config_name);
+ sasl->config_name = pn_strdup(name);
}
void pn_sasl_config_path(pn_sasl_t *sasl0, const char *dir)
@@ -487,6 +488,7 @@ void pn_sasl_free(pn_transport_t *transport)
free(sasl->selected_mechanism);
free(sasl->included_mechanisms);
free(sasl->password);
+ free(sasl->config_name);
free(sasl->config_dir);
free(sasl->external_auth);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[37/50] qpid-proton git commit: PROTON-781: Added reactor support to
the Ruby Event class.
Posted by mc...@apache.org.
PROTON-781: Added reactor support to the Ruby Event class.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/07ddaaf3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/07ddaaf3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/07ddaaf3
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 07ddaaf309e36f458f2e4dca6c388902d3c6a865
Parents: 83e923b
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon May 18 15:02:18 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/event/event.rb | 38 ++++++++++++++++++++------
1 file changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/07ddaaf3/proton-c/bindings/ruby/lib/event/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/event/event.rb b/proton-c/bindings/ruby/lib/event/event.rb
index dd5d869..e839f63 100644
--- a/proton-c/bindings/ruby/lib/event/event.rb
+++ b/proton-c/bindings/ruby/lib/event/event.rb
@@ -37,6 +37,13 @@ module Qpid::Proton
# be generated.
NONE = event_type(:PN_EVENT_NONE)
+ # A reactor has been started.
+ REACTOR_INIT = event_type(:PN_REACTOR_INIT)
+ # A reactor has no more events to process.
+ REACTOR_QUIESCED = event_type(:PN_REACTOR_QUIESCED)
+ # A reactor has been stopred.
+ REACTOR_FINAL = event_type(:PN_REACTOR_FINAL)
+
# A timer event has occurred.
TIMER_TASK = event_type(:PN_TIMER_TASK)
@@ -199,17 +206,32 @@ module Qpid::Proton
#
def dispatch(handler, type = nil)
type = @type if type.nil?
- #notify any and all attached handlers
- if handler.respond_to?(:handlers?) && handler.handlers?
- handler.handlers.each {|hndlr| self.dispatch(hndlr, type)}
- end
- if handler.respond_to?(type.method)
- handler.__send__(type.method, self)
- elsif handler.respond_to?(:on_unhandled)
- handler.on_unhandled(self)
+ if handler.is_a?(Qpid::Proton::Handler::WrappedHandler)
+ Cproton.pn_handler_dispatch(handler.impl, @impl, type.number)
+ else
+ result = Qpid::Proton::Event.dispatch(handler, type.method, self)
+ if (result != "DELEGATED") && handler.respond_to?(:handlers)
+ handler.handlers.each do |hndlr|
+ self.dispatch(hndlr)
+ end
+ end
end
end
+ # Returns the reactor for this event.
+ #
+ # @return [Reactor, nil] The reactor.
+ #
+ def reactor
+ impl = Cproton.pn_event_reactor(@impl)
+ Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl)
+ end
+
+ def container
+ impl = Cproton.pn_event_reactor(@impl)
+ Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl)
+ end
+
# Returns the transport for this event.
#
# @return [Transport, nil] The transport.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[14/50] qpid-proton git commit: PROTON-916: Avoid unnecessary heap
allocation
Posted by mc...@apache.org.
PROTON-916: Avoid unnecessary heap allocation
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/638c18b3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/638c18b3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/638c18b3
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 638c18b33d4dd8f10692b975f522053a2ed4f980
Parents: 5b611b7
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Jun 17 18:17:31 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Jun 17 18:28:39 2015 -0400
----------------------------------------------------------------------
proton-c/src/sasl/cyrus_sasl.c | 2 +-
proton-c/src/sasl/sasl.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/638c18b3/proton-c/src/sasl/cyrus_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c
index b42ffa5..c84d0af 100644
--- a/proton-c/src/sasl/cyrus_sasl.c
+++ b/proton-c/src/sasl/cyrus_sasl.c
@@ -245,7 +245,7 @@ bool pni_init_server(pn_transport_t* transport)
if (result!=SASL_OK) break;
}
- result = sasl_server_init(NULL, sasl->config_name);
+ result = sasl_server_init(NULL, sasl->config_name ? sasl->config_name : "proton-server");
if (result!=SASL_OK) break;
result = sasl_server_new(amqp_service, NULL, NULL, NULL, NULL, NULL, 0, &cyrus_conn);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/638c18b3/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index 47084ee..2e6be06 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -366,7 +366,7 @@ pn_sasl_t *pn_sasl(pn_transport_t *transport)
sasl->included_mechanisms = NULL;
sasl->username = NULL;
sasl->password = NULL;
- sasl->config_name = pn_strdup(sasl->client ? "proton-client" : "proton-server");
+ sasl->config_name = NULL;
sasl->config_dir = sasl_config_path ? pn_strdup(sasl_config_path) : NULL;
sasl->remote_fqdn = NULL;
sasl->external_auth = NULL;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[40/50] qpid-proton git commit: PROTON-781: Added the set of
LinkOption classes to Ruby.
Posted by mc...@apache.org.
PROTON-781: Added the set of LinkOption classes to Ruby.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c84aace4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c84aace4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c84aace4
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: c84aace4e1de46b413fc7861a3f823851b758c14
Parents: e721358
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon May 4 13:26:26 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
.../bindings/ruby/lib/reactor/link_option.rb | 90 ++++++++++++++++++++
2 files changed, 91 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c84aace4/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index ba1e66e..1d614a4 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -107,6 +107,7 @@ require "reactor/connector"
require "reactor/backoff"
require "reactor/session_per_connection"
require "reactor/container"
+require "reactor/link_option"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c84aace4/proton-c/bindings/ruby/lib/reactor/link_option.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/link_option.rb b/proton-c/bindings/ruby/lib/reactor/link_option.rb
new file mode 100644
index 0000000..628a811
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/link_option.rb
@@ -0,0 +1,90 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class LinkOption
+ def apply(link)
+ end
+
+ # Subclasses should override this to selectively apply an option.
+ def test(link)
+ true
+ end
+ end
+
+ class AtMostOne < LinkOption
+ def apply(link)
+ link.snd_settle_mod = Link::SND_SETTLED
+ end
+ end
+
+ class AtLeastOnce < LinkOption
+ def apply(link)
+ link.snd_settle_mode = Link::SND_UNSETTLED
+ link.rcv_settle_mode = Link::RCV_FIRST
+ end
+ end
+
+ class SenderOption < LinkOption
+ def test(link)
+ link.sender?
+ end
+ end
+
+ class ReceiverOption < LinkOption
+ def test(link)
+ link.receiver?
+ end
+ end
+
+ class DynamicNodeProperties < LinkOption
+ def initialize(properties = {})
+ @properties = []
+ properties.each do |property|
+ @properties << property.to_sym
+ end
+ end
+
+ def apply(link)
+ if link.receiver?
+ link.source.properties.dict = @properties
+ else
+ link.target.properties.dict = @properties
+ end
+ end
+ end
+
+ class Filter < ReceiverOption
+ def initialize(filter_set = {})
+ @filter_set = filter_set
+ end
+
+ def apply(receiver)
+ receiver.source.filter.dict = @filter_set
+ end
+ end
+
+ #class Selector < Filter
+ # def initialize(value, name = 'selector')
+ #
+ # end
+ #end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[33/50] qpid-proton git commit: PROTON-781: Added the Handler mixin
to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added the Handler mixin to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9dcf369b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9dcf369b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9dcf369b
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 9dcf369b61c46833768350227045e8ff47fb1f5d
Parents: a62d922
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 08:06:19 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/util/handler.rb | 41 +++++++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9dcf369b/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 0c84f20..03f5632 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -41,6 +41,7 @@ require "util/class_wrapper"
require "util/engine"
require "util/uuid"
require "util/timeout"
+require "util/handler"
# Types
require "types/strings"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9dcf369b/proton-c/bindings/ruby/lib/util/handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/handler.rb b/proton-c/bindings/ruby/lib/util/handler.rb
new file mode 100644
index 0000000..e7d07b1
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/handler.rb
@@ -0,0 +1,41 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Util
+
+ # @private
+ module Handler
+
+ def chandler(handler, on_error)
+ return nil if handler.nil?
+
+ if handler.instance_of?(Qpid::Proton::Handler::WrappedHandler)
+ impl = handler.impl
+ Cproton.pn_incref(impl)
+ return impl
+ else
+ cadaptor = Qpid::Proton::Handler::CAdaptor.new(handler, on_error)
+ rbhandler = Cproton.pn_rbhandler(cadaptor)
+ return rbhandler
+ end
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[42/50] qpid-proton git commit: PROTON-781: Reactive Ruby examples
Posted by mc...@apache.org.
PROTON-781: Reactive Ruby examples
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/717377a2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/717377a2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/717377a2
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 717377a2da1f347b20ab4f81dce2fecf97d1a463
Parents: 3211bd5
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Tue May 26 15:34:11 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
examples/ruby/lib/debugging.rb | 26 +++
examples/ruby/lib/send_and_receive.rb | 90 +++++++++++
examples/ruby/reactor/README.md | 103 ++++++++++++
examples/ruby/reactor/broker.rb | 200 ++++++++++++++++++++++++
examples/ruby/reactor/client.rb | 68 ++++++++
examples/ruby/reactor/direct_recv.rb | 60 +++++++
examples/ruby/reactor/direct_send.rb | 59 +++++++
examples/ruby/reactor/helloworld.rb | 69 ++++++++
examples/ruby/reactor/helloworld_direct.rb | 74 +++++++++
examples/ruby/reactor/server.rb | 64 ++++++++
examples/ruby/reactor/simple_recv.rb | 58 +++++++
examples/ruby/reactor/simple_send.rb | 55 +++++++
12 files changed, 926 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/lib/debugging.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/lib/debugging.rb b/examples/ruby/lib/debugging.rb
new file mode 100644
index 0000000..5065d51
--- /dev/null
+++ b/examples/ruby/lib/debugging.rb
@@ -0,0 +1,26 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Debugging
+
+ def debug(text)
+ print "[#{Time.now.strftime('%s')}] #{text}\n"
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/lib/send_and_receive.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/lib/send_and_receive.rb b/examples/ruby/lib/send_and_receive.rb
new file mode 100644
index 0000000..9fd7417
--- /dev/null
+++ b/examples/ruby/lib/send_and_receive.rb
@@ -0,0 +1,90 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+class ExampleSend < Qpid::Proton::Handler::MessagingHandler
+
+ attr_reader :url
+
+ def initialize(url, expected)
+ super()
+ @url = url
+ @sent = 0
+ @confirmed = 0
+ @expected = expected
+ end
+
+ def on_sendable(event)
+ while event.sender.credit > 0 && @sent < @expected
+ msg = Qpid::Proton::Message.new
+ msg.body = "sequence #{@sent}"
+ msg.id = @sent
+ event.sender.send(msg)
+ @sent = @sent + 1
+ end
+ end
+
+ def on_accepted(event)
+ @confirmed = @confirmed + 1
+ if self.finished?
+ puts "#{@expected > 1 ? 'All ' : ''}#{@expected} message#{@expected > 1 ? 's' : ''} confirmed!"
+ event.connection.close
+ end
+ end
+
+ def on_disconnected(event)
+ @sent = @confirmed
+ end
+
+ def finished?
+ @confirmed == @expected
+ end
+
+end
+
+class ExampleReceive < Qpid::Proton::Handler::MessagingHandler
+
+ attr_reader :url
+
+ def initialize(url, expected)
+ super()
+ @url = url
+ @expected = expected
+ @received = 0
+ end
+
+ def on_message(event)
+ if event.message.id.nil? || event.message.id < @received
+ puts "Missing or old message id: id=#{event.message.id}"
+ return
+ end
+ if @expected.zero? || (@received < @expected)
+ puts "Received: #{event.message.body}"
+ @received = @received + 1
+ if finished?
+ event.receiver.close
+ event.connection.close
+ end
+ end
+ end
+
+ def finished?
+ @received == @expected
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/README.md
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/README.md b/examples/ruby/reactor/README.md
new file mode 100644
index 0000000..38cc6ba
--- /dev/null
+++ b/examples/ruby/reactor/README.md
@@ -0,0 +1,103 @@
+## What Is The Reactor?
+
+A little outside of the scope of this document, but the reactor is an event source for letting an application know about events in the Proton messaging system. With this set of APIs an application can be register handlers that are notified when a connection is created, a message received, or a session closes.
+
+### Handlers
+
+An application creates **handlers**, objects which provide methods through which the reactor notifies the application's components of events and allows them each to handle the ones in which they are interested (see the Chain Of Responsibility design pattern for more on this idea). There are some pre-defined handlers for responding to incoming message events, outgoing message events, data flow and managing the AMQP endpoints. Look in the **Qpid::Proton::Handlers** package for more details on these classes.
+
+## Simple Reactor Examples
+
+### The Broker
+
+The reactor examples come with a sample broker which can be used by other examples and which also works as an example itself. For now we'll just start up the broker example and tell it to listen on port 8888:
+
+````
+$ ruby ../examples/ruby/reactor/broker.rb --address=0.0.0.0:8888
+Listening on 0.0.0.0:8888
+````
+
+This example broker will receive messages, create queues as needed, and deliver messages to endpoints.
+
+### Hello World Using A Broker
+
+Our first example creates an endpoint that sends messages to a queue to which it is subscribed. So it both sends and receives its message in one pass.
+
+To start it, simply run:
+
+```
+$ ruby ../examples/ruby/reactor/helloworld.rb --address=0.0.0.0:8888 --queue=examples
+Hello world!
+```
+
+As you can see, the classic message was output by the example. Now let's take a look at what's going on under the covers.
+
+#### Events When Talking To A Broker
+
+The following events occur while **helloworld.rb** runs:
+
+ * **on_start** - Fired when the application is started.
+ * **on_sendable** - Fired when a message can be sent.
+ * **on_message** - Fired when a message is received.
+
+### Hello World Without A Broker required
+
+The next example we'll look at will send the classic "Hello world" message to itself directly. This example shows some very fundamental elements of the reactor APIs that you should understand.
+
+To launch the example:
+
+```
+ $ ruby helloworld_direct.rb --address=0.0.0.0:8888/examples
+ Hello world!
+```
+
+Not very different from the example that uses the broker, which is what we'd expect from the outside. But let's take a look inside of the example and see how it's different at that level
+
+The direct version takes on the responsibility for listening to incoming connections as well as making an outgoing connection. So we see the following additional events occurring:
+
+ * **on_accepted** - Fired when a message is received.
+ * **on_connection_closed** - Fired when an endpoint closes its connection.
+
+## More Complex Reactor Examples
+
+Now that we've covered the basics with the archetypical hello world app, let's look at some more interesting examples.
+
+There are four example applications that demonstrate how to send and receive messages both directly and through an intermediary, such as a broker:
+
+ * **simple_send.rb** - sends messages to a receiver at a specific address and receives responses via an intermediary,
+ * **simple_recv.rb** - receives messages from via an intermediary,
+ * **direct_send.rb** - sends messages directly to a receiver and listens for responses itself, and
+ * **direct_recv.rb** - receives messages directly.
+
+ Simple send and direct send may, at first, seem to be so similar that you wonder why they're not just the same applciation. And I know for me I was wonder as I wrote the list above why there were two examples. The reason is that **simple_send.rb** uses the intermediary transfer responses to the messages it sends, while **direct_send.rb** uses an *Acceptor* to listen for an process responses.
+
+ You can use the examples in the follow ways:
+
+ ```
+ simple_send.rb -> broker <- simple_recv.rb
+ simple_send.rb -> direct_recv.rb
+ direct_send.rb -> simple_recv.rb
+ ```
+
+In this set of examples we see the following event occurring, in addition to what we've seen before:
+
+ * **on_disconnected** - Fired when the transport is closed.
+
+## Now About That Broker example
+
+The **broker.rb** example application is a nice demonstration of doing something more interesting in Ruby with Proton.
+
+The way the broker works is to listen to incoming connections, examine the components of the address for that connection, attach that connection to an exchange managing that address and then it sends any messages destined for that address to them.
+
+The components of the broker example include:
+ * **Broker** - A class that extends the MessagingHandler class. It accepts incoming connections, manages subscribing them to exchanges, and transfers messages between them.
+ * **Exchange** - A class that represents a message queue, tracking what endpoints are subscribed to it.
+
+The Broker manages a map connecting a queue address to the instance of Exchange that holds references to the endpoints of interest.
+
+The broker application demonstrates a new set of reactor events:
+
+ * **on_link_opening** - Fired when a remote link is opened but the local end is not yet open. From this event the broker grabs the address and subscribes the link to an exchange for that address.
+ * **on_link_closing** - Fired when a remote link is closed but the local end is still open. From this event the broker grabs the address and unsubscribes the link from that exchange.
+ * **on_connection_closing** - Fired when a remote connection is closed but the local end is still open.
+ * **on_disconnected** - Fired when the protocol transport has closed. The broker removes all links for the disconnected connection, avoiding workign with endpoints that are now gone.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/broker.rb b/examples/ruby/reactor/broker.rb
new file mode 100644
index 0000000..9d7e5be
--- /dev/null
+++ b/examples/ruby/reactor/broker.rb
@@ -0,0 +1,200 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+require 'pathname'
+
+require_relative '../lib/debugging'
+
+class Exchange
+
+ include Debugging
+
+ def initialize(dynamic = false)
+ @dynamic = dynamic
+ @queue = Queue.new
+ @consumers = []
+ end
+
+ def subscribe(consumer)
+ debug("subscribing #{consumer}") if $options[:debug]
+ @consumers << (consumer)
+ debug(" there are #{@consumers.size} consumers") if $options[:debug]
+ end
+
+ def unsubscribe(consumer)
+ debug("unsubscribing #{consumer}") if $options[:debug]
+ if @consumers.include?(consumer)
+ @consumers.delete(consumer)
+ else
+ debug(" consumer doesn't exist") if $options[:debug]
+ end
+ debug(" there are #{@consumers.size} consumers") if $options[:debug]
+ @consumers.empty? && (@dynamic || @queue.empty?)
+ end
+
+ def publish(message)
+ debug("queueing message: #{message.body}") if $options[:debug]
+ @queue << message
+ self.dispatch
+ end
+
+ def dispatch(consumer = nil)
+ debug("dispatching: consumer=#{consumer}") if $options[:debug]
+ if consumer
+ c = [consumer]
+ else
+ c = @consumers
+ end
+
+ while self.deliver_to(c) do
+ end
+ end
+
+ def deliver_to(consumers)
+ debug("delivering to #{consumers.size} consumer(s)") if $options[:debug]
+ result = false
+ consumers.each do |consumer|
+ debug(" current consumer=#{consumer} credit=#{consumer.credit}") if $options[:debug]
+ if consumer.credit > 0 && !@queue.empty?
+ consumer.send(@queue.pop(true))
+ result = true
+ end
+ end
+ return result
+ end
+
+end
+
+class Broker < Qpid::Proton::Handler::MessagingHandler
+
+ include Debugging
+
+ def initialize(url)
+ super()
+ @url = url
+ @queues = {}
+ end
+
+ def on_start(event)
+ debug("on_start event") if $options[:debug]
+ @acceptor = event.container.listen(@url)
+ print "Listening on #{@url}\n"
+ end
+
+ def queue(address)
+ debug("fetching queue for #{address}: (there are #{@queues.size} queues)") if $options[:debug]
+ unless @queues.has_key?(address)
+ debug(" creating new queue") if $options[:debug]
+ @queues[address] = Exchange.new
+ else
+ debug(" using existing queue") if $options[:debug]
+ end
+ result = @queues[address]
+ debug(" returning #{result}") if $options[:debug]
+ return result
+ end
+
+ def on_link_opening(event)
+ debug("processing on_link_opening") if $options[:debug]
+ debug("link is#{event.link.sender? ? '' : ' not'} a sender") if $options[:debug]
+ if event.link.sender?
+ if event.link.remote_source.dynamic?
+ address = generate_uuid
+ event.link.source.address = address
+ q = Exchange.new(true)
+ @queues[address] = q
+ q.subscribe(event.link)
+ elsif event.link.remote_source.address
+ event.link.source.address = event.link.remote_source.address
+ self.queue(event.link.source.address).subscribe(event.link)
+ end
+ elsif event.link.remote_target.address
+ event.link.target.address = event.link.remote_target.address
+ end
+ end
+
+ def unsubscribe(link)
+ debug("unsubscribing #{link.address}") if $options[:debug]
+ if @queues.has_key?(link.source.address)
+ if @queues[link.source.address].unsubscribe(link)
+ @queues.delete(link.source.address)
+ end
+ end
+ end
+
+ def on_link_closing(event)
+ self.unsubscribe(event.link) if event.link.sender?
+ end
+
+ def on_connection_closing(event)
+ self.remove_stale_consumers(event.connection)
+ end
+
+ def on_disconnected(event)
+ self.remove_stale_consumers(event.connection)
+ end
+
+ def remove_stale_consumers(connection)
+ l = connection.link_head(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
+ while !l.nil?
+ self.unsubscribe(l) if l.sender?
+ l = l.next(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
+ end
+ end
+
+ def on_sendable(event)
+ debug("on_sendable event") if $options[:debug]
+ q = self.queue(event.link.source.address)
+ debug(" dispatching #{event.message} to #{q}") if $options[:debug]
+ q.dispatch(event.link)
+ end
+
+ def on_message(event)
+ debug("on_message event") if $options[:debug]
+ q = self.queue(event.link.target.address)
+ debug(" dispatching #{event.message} to #{q}") if $options[:debug]
+ q.publish(event.message)
+ end
+
+end
+
+$options = {
+ :address => "localhost:5672",
+ :debug => false
+}
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: #{Pathname.new(__FILE__).basename} [$options]"
+
+ opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{$options[:address]}).") do |address|
+ $options[:address] = address
+ end
+
+ opts.on("-d", "--debug", "Enable debugging output (def. #{$options[:debug]})") do
+ $options[:debug] = true
+ end
+
+end.parse!
+
+begin
+ Qpid::Proton::Reactor::Container.new(Broker.new($options[:address])).run
+rescue Interrupt
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/client.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/client.rb b/examples/ruby/reactor/client.rb
new file mode 100644
index 0000000..8bb58da
--- /dev/null
+++ b/examples/ruby/reactor/client.rb
@@ -0,0 +1,68 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+
+class Client < Qpid::Proton::Handler::MessagingHandler
+
+ def initialize(url, requests)
+ super()
+ @url = url
+ @requests = requests
+ end
+
+ def on_start(event)
+ @sender = event.container.create_sender(@url)
+ @receiver = event.container.create_receiver(@sender.connection, :dynamic => true)
+ end
+
+ def next_request
+ if @receiver.remote_source.address
+ req = Qpid::Proton::Message.new
+ req.reply_to = @receiver.remote_source.address
+ req.body = @requests.first
+ puts "-> #{req.body}"
+ @sender.send(req)
+ end
+ end
+
+ def on_link_opened(event)
+ if event.receiver == @receiver
+ next_request
+ end
+ end
+
+ def on_message(event)
+ puts "<- #{event.message.body}"
+ @requests.delete_at(0)
+ if !@requests.empty?
+ next_request
+ else
+ event.connection.close
+ end
+ end
+
+end
+
+REQUESTS = ["Twas brillig, and the slithy toves",
+ "Did gire and gymble in the wabe.",
+ "All mimsy were the borogroves,",
+ "And the mome raths outgrabe."]
+
+Qpid::Proton::Reactor::Container.new(Client.new("0.0.0.0:5672/examples", REQUESTS)).run
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/direct_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/direct_recv.rb b/examples/ruby/reactor/direct_recv.rb
new file mode 100644
index 0000000..2e19b04
--- /dev/null
+++ b/examples/ruby/reactor/direct_recv.rb
@@ -0,0 +1,60 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+require_relative '../lib/send_and_receive'
+
+class DirectReceive < ExampleReceive
+
+ def initialize(url, expected)
+ super
+ end
+
+ def on_start(event)
+ @acceptor = event.container.listen(self.url)
+ end
+
+ def on_message(event)
+ super(event)
+ @acceptor.close if self.finished?
+ end
+
+end
+
+options = {
+ :address => "localhost:5672/examples",
+ :messages => 100,
+}
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: simple_send.rb [options]"
+
+ opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+ options[:address] = address
+ end
+
+ opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
+ OptionParser::DecimalInteger) do |messages|
+ options[:messages] = messages
+ end
+end.parse!
+
+Qpid::Proton::Reactor::Container.new(DirectReceive.new(options[:address], options[:messages])).run
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/direct_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/direct_send.rb b/examples/ruby/reactor/direct_send.rb
new file mode 100644
index 0000000..22ce7de
--- /dev/null
+++ b/examples/ruby/reactor/direct_send.rb
@@ -0,0 +1,59 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+require_relative '../lib/send_and_receive'
+
+options = {
+ :address => "localhost:5672/examples",
+ :messages => 100,
+}
+
+class SimpleSend < ExampleSend
+
+ def initialize(url, messages)
+ super(url, messages)
+ end
+
+ def on_start(event)
+ @acceptor = event.container.listen(url)
+ end
+
+end
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: simple_send.rb [options]"
+
+ opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+ options[:address] = address
+ end
+
+ opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
+ OptionParser::DecimalInteger) do |messages|
+ options[:messages] = messages
+ end
+end.parse!
+
+begin
+ Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages])).run
+rescue Interrupt => error
+ puts "ERROR: #{error}"
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/helloworld.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/helloworld.rb b/examples/ruby/reactor/helloworld.rb
new file mode 100644
index 0000000..03eb561
--- /dev/null
+++ b/examples/ruby/reactor/helloworld.rb
@@ -0,0 +1,69 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+class HelloWorld < Qpid::Proton::Handler::MessagingHandler
+
+ def initialize(server, address)
+ super()
+ @server = server
+ @address = address
+ end
+
+ def on_start(event)
+ conn = event.container.connect(:address => @server)
+ event.container.create_sender(conn, :target => @address)
+ event.container.create_receiver(conn, :source => @address)
+ end
+
+ def on_sendable(event)
+ msg = Qpid::Proton::Message.new
+ msg.body = "Hello world!"
+ event.sender.send(msg)
+ event.sender.close
+ end
+
+ def on_message(event)
+ puts event.message.body
+ event.connection.close
+ end
+end
+
+options = {
+ :address => "localhost:5672",
+ :queue => "examples"
+}
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: helloworld_direct.rb [options]"
+
+ opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+ options[:address] = address
+ end
+
+ opts.on("-q", "--queue=QUEUE", "Send messages to QUEUE (def. #{options[:queue]})") do |queue|
+ options[:queue] = queue
+ end
+
+end.parse!
+
+hw = HelloWorld.new(options[:address], "examples")
+Qpid::Proton::Reactor::Container.new(hw).run
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/helloworld_direct.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/helloworld_direct.rb b/examples/ruby/reactor/helloworld_direct.rb
new file mode 100644
index 0000000..e98cc1f
--- /dev/null
+++ b/examples/ruby/reactor/helloworld_direct.rb
@@ -0,0 +1,74 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+options = {
+ :address => "localhost:5672/examples",
+}
+
+class HelloWorldDirect < Qpid::Proton::Handler::MessagingHandler
+
+ include Qpid::Proton::Util::Wrapper
+
+ def initialize(url)
+ super()
+ @url = url
+ end
+
+ def on_start(event)
+ @acceptor = event.container.listen(@url)
+ event.container.create_sender(@url)
+ end
+
+ def on_sendable(event)
+ msg = Qpid::Proton::Message.new
+ msg.body = "Hello world!"
+ event.sender.send(msg)
+ event.sender.close
+ end
+
+ def on_message(event)
+ puts "#{event.message.body}"
+ end
+
+ def on_accepted(event)
+ event.connection.close
+ end
+
+ def on_connection_closed(event)
+ @acceptor.close
+ end
+
+end
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: helloworld_direct.rb [options]"
+
+ opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+ options[:address] = address
+ end
+
+end.parse!
+
+begin
+ Qpid::Proton::Reactor::Container.new(HelloWorldDirect.new(options[:address])).run
+rescue Interrupt => error
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/server.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/server.rb b/examples/ruby/reactor/server.rb
new file mode 100644
index 0000000..e149dba
--- /dev/null
+++ b/examples/ruby/reactor/server.rb
@@ -0,0 +1,64 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+
+class Server < Qpid::Proton::Handler::MessagingHandler
+
+ def initialize(url, address)
+ super()
+ @url = url
+ @address = address
+ @senders = {}
+ end
+
+ def on_start(event)
+ puts "Listening on #{@url}"
+ @container = event.container
+ @conn = @container.connect(:address => @url)
+ @receiver = @container.create_receiver(@conn, :source => @address)
+ @relay = nil
+ end
+
+ def on_connection_opened(event)
+ if event.connection.remote_offered_capabilities &&
+ event.connection.remote_offered_capabilities.contain?("ANONYMOUS-RELAY")
+ @relay = @container.create_sender(@conn, nil)
+ end
+ end
+
+ def on_message(event)
+ msg = event.message
+ puts "<- #{msg.body}"
+ sender = @relay || @senders[msg.reply_to]
+ if sender.nil?
+ sender = @container.create_sender(@conn, :target => msg.reply_to)
+ @senders[msg.reply_to] = sender
+ end
+ reply = Qpid::Proton::Message.new
+ reply.address = msg.reply_to
+ reply.body = msg.body.upcase
+ puts "-> #{reply.body}"
+ reply.correlation_id = msg.correlation_id
+ sender.send(reply)
+ end
+
+end
+
+Qpid::Proton::Reactor::Container.new(Server.new("0.0.0.0:5672", "examples")).run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/simple_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/simple_recv.rb b/examples/ruby/reactor/simple_recv.rb
new file mode 100644
index 0000000..55a37ee
--- /dev/null
+++ b/examples/ruby/reactor/simple_recv.rb
@@ -0,0 +1,58 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+require_relative '../lib/send_and_receive'
+
+class Receiver < ExampleReceive
+
+ def initialize(url, count)
+ super(url, count)
+ end
+
+ def on_start(event)
+ event.container.create_receiver(@url)
+ end
+
+end
+
+options = {
+ :address => "localhost:5672/examples",
+ :messages => 100,
+}
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: simple_send.rb [options]"
+
+ opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+ options[:address] = address
+ end
+
+ opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
+ OptionParser::DecimalInteger) do |messages|
+ options[:messages] = messages
+ end
+end.parse!
+
+begin
+ Qpid::Proton::Reactor::Container.new(Receiver.new(options[:address], options[:messages])).run
+rescue Interrupt
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/reactor/simple_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/simple_send.rb b/examples/ruby/reactor/simple_send.rb
new file mode 100644
index 0000000..1dd4150
--- /dev/null
+++ b/examples/ruby/reactor/simple_send.rb
@@ -0,0 +1,55 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+require_relative '../lib/send_and_receive'
+
+options = {
+ :address => "localhost:5672/examples",
+ :messages => 100,
+}
+
+class SimpleSend < ExampleSend
+
+ def initialize(url, messages)
+ super(url, messages)
+ end
+
+ def on_start(event)
+ event.container.create_sender(url)
+ end
+
+end
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: simple_send.rb [options]"
+
+ opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+ options[:address] = address
+ end
+
+ opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
+ OptionParser::DecimalInteger) do |messages|
+ options[:messages] = messages
+ end
+end.parse!
+
+Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages])).run
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[25/50] qpid-proton git commit: PROTON-781: Added the Timeout mixin
to the Ruby APIs.
Posted by mc...@apache.org.
PROTON-781: Added the Timeout mixin to the Ruby APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a62d9220
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a62d9220
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a62d9220
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: a62d92203bf094eea2bcf7769d4ca6f288f2a8db
Parents: 1c20ad6
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon Mar 2 15:42:20 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/util/timeout.rb | 50 +++++++++++++++++++++++++
2 files changed, 51 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a62d9220/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 5b0d23f..0c84f20 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -40,6 +40,7 @@ require "util/wrapper"
require "util/class_wrapper"
require "util/engine"
require "util/uuid"
+require "util/timeout"
# Types
require "types/strings"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a62d9220/proton-c/bindings/ruby/lib/util/timeout.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/timeout.rb b/proton-c/bindings/ruby/lib/util/timeout.rb
new file mode 100644
index 0000000..f4647f5
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/timeout.rb
@@ -0,0 +1,50 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Util
+
+ # Provides methods for converting between milliseconds, seconds
+ # and timeout values.
+ #
+ # @private
+ module Timeout
+
+ def sec_to_millis(s)
+ return (s * 1000).to_int
+ end
+
+ def millis_to_sec(ms)
+ return (ms.to_f / 1000.0).to_int
+ end
+
+ def timeout_to_millis(s)
+ return Cproton::PN_MILLIS_MAX if s.nil?
+
+ return sec_to_millis(s)
+ end
+
+ def millis_to_timeout(ms)
+ return nil if ms == Cproton::PN_MILLIS_MAX
+
+ return millis_to_sec(ms)
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[11/50] qpid-proton git commit: PROTON-914: Fix for getting the SSL
peer hostname in Ruby.
Posted by mc...@apache.org.
PROTON-914: Fix for getting the SSL peer hostname in Ruby.
Previously the call was returning the result code rather than the actual
hostname value.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cbb68004
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cbb68004
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cbb68004
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: cbb6800496e88a0a4f22523c0f0f68afd3424323
Parents: 0f90a7e
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Jun 17 11:12:32 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Wed Jun 17 11:51:40 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/ssl.rb | 18 +++++++++++-------
proton-c/bindings/ruby/lib/core/transport.rb | 5 ++---
proton-c/bindings/ruby/ruby.i | 13 +------------
3 files changed, 14 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/lib/core/ssl.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/ssl.rb b/proton-c/bindings/ruby/lib/core/ssl.rb
index 9c4a3e9..0b16075 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -66,11 +66,6 @@ module Qpid::Proton
# @private
PROTON_METHOD_PREFIX = "pn_ssl"
- # @!attribute peer_hostname
- #
- # @return [String] The peer hostname.
- proton_accessor :peer_hostname
-
# @private
include Util::ErrorHandler
@@ -108,10 +103,10 @@ module Qpid::Proton
def initialize(impl, domain, session_details, session_id)
@impl = impl
- @domain = domain
+ @domain = domain.impl unless domain.nil?
@session_details = session_details
@session_id = session_id
- Cproton.pn_ssl_init(@impl, @domain.impl, @session_id)
+ Cproton.pn_ssl_init(@impl, @domain, @session_id)
end
public
@@ -155,6 +150,15 @@ module Qpid::Proton
Cproton.pn_ssl_resume_status(@impl)
end
+ # Gets the peer hostname.
+ #
+ # @return [String] The peer hostname.
+ def peer_hostname
+ (error, name) = Cproton.pn_ssl_get_peer_hostname(@impl, 1024)
+ raise SSLError.new if error < 0
+ return name
+ end
+
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/lib/core/transport.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transport.rb b/proton-c/bindings/ruby/lib/core/transport.rb
index 206f97d..9ba5dc8 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -398,13 +398,12 @@ module Qpid::Proton
# @return [SSL] The SSL object.
#
def ssl(domain = nil, session_details = nil)
- self.ssl = SSL.create(self, domain, session_details) if self.ssl.nil?
- self.ssl
+ @ssl ||= SSL.create(self, domain, session_details) if @ssl.nil?
end
# @private
def ssl?
- self.respond_to?(:ssl) && !self.ssl.nil?
+ !@ssl.nil?
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/ruby.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i
index 0534808..678a085 100644
--- a/proton-c/bindings/ruby/ruby.i
+++ b/proton-c/bindings/ruby/ruby.i
@@ -556,18 +556,7 @@ VALUE pni_address_of(void *object) {
// %}
//%ignore pn_collector_put;
-%rename(pn_ssl_get_peer_hostname) wrap_pn_ssl_get_peer_hostname;
-%inline %{
- int wrap_pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE) {
- ssize_t size = pn_ssl_get_peer_hostname(ssl, OUTPUT, *OUTPUT_SIZE);
- if (size >= 0) {
- *OUTPUT_SIZE = size;
- } else {
- *OUTPUT_SIZE = 0;
- }
- return size;
- }
- %}
+int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
%ignore pn_ssl_get_peer_hostname;
%include "proton/cproton.i"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[35/50] qpid-proton git commit: PROTON-781: Added the Task class to
the Ruby reactor APIs.
Posted by mc...@apache.org.
PROTON-781: Added the Task class to the Ruby reactor APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c690e566
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c690e566
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c690e566
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: c690e566db6952fc95d6f5353276c24f8e6c0954
Parents: 7c93d88
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon Feb 23 16:19:33 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 3 ++
proton-c/bindings/ruby/lib/reactor/task.rb | 39 +++++++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c690e566/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index a60a028..f3da844 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -92,6 +92,9 @@ require "handler/outgoing_message_handler"
require "handler/c_flow_controller"
require "handler/messaging_handler"
+# Reactor classes
+require "reactor/task"
+
module Qpid::Proton
# @private
def self.registry
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c690e566/proton-c/bindings/ruby/lib/reactor/task.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/task.rb b/proton-c/bindings/ruby/lib/reactor/task.rb
new file mode 100644
index 0000000..6818ed2
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/task.rb
@@ -0,0 +1,39 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class Task
+
+ # @private
+ include Qpid::Proton::Util::Wrapper
+
+ def self.wrap(impl)
+ return nil if impl.nil?
+ self.fetch_instance(impl, :pn_task_attachments) || Task.new(impl)
+ end
+
+ def initialize(impl)
+ @impl = impl
+ self.class.store_instance(self, :pn_task_attachments)
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[02/50] qpid-proton git commit: PROTON-909: Tests for Cyrus SASL mechs
Posted by mc...@apache.org.
PROTON-909: Tests for Cyrus SASL mechs
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/990b11e8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/990b11e8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/990b11e8
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 990b11e8a3e3b7a63c891b42e22ea3d180278e55
Parents: e55fe32
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Jun 2 03:26:44 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Jun 11 16:20:28 2015 -0400
----------------------------------------------------------------------
proton-j/src/main/resources/csasl.py | 16 ++
tests/python/proton_tests/sasl.py | 248 +++++++++++++++++++++++++++++-
2 files changed, 258 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/990b11e8/proton-j/src/main/resources/csasl.py
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/csasl.py b/proton-j/src/main/resources/csasl.py
index 32f8039..b36b104 100644
--- a/proton-j/src/main/resources/csasl.py
+++ b/proton-j/src/main/resources/csasl.py
@@ -62,6 +62,22 @@ SASL_OUTCOMES_J2P = {
def pn_transport_require_auth(transport, require):
transport.impl.sasl().allowSkip(not require)
+# TODO: Placeholders
+def pn_transport_is_authenticated(transport):
+ raise Skipped('Not supported in Proton-J')
+
+def pn_transport_is_encrypted(transport):
+ raise Skipped('Not supported in Proton-J')
+
+def pn_transport_get_user(transport):
+ raise Skipped('Not supported in Proton-J')
+
+def pn_connection_set_user(connection, user):
+ pass
+
+def pn_connection_set_password(connection, password):
+ pass
+
def pn_sasl_allowed_mechs(sasl, mechs):
sasl.setMechanisms(*mechs.split())
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/990b11e8/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 68fb6e3..91b3e69 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -18,9 +18,69 @@
#
import sys, os, common
+from string import Template
+import subprocess
+
from proton import *
from common import pump, Skipped
+from cproton import *
+
+def _sslCertpath(file):
+ """ Return the full path to the certificate,keyfile, etc.
+ """
+ return os.path.join(os.path.dirname(__file__),
+ "ssl_db/%s" % file)
+
+def _cyrusSetup(conf_dir):
+ """Write out simple SASL config
+ """
+ t = Template("""sasldb_path: ${db}
+mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
+""")
+ subprocess.call(args=['rm','-rf',conf_dir])
+ os.mkdir(conf_dir)
+ db = os.path.abspath(os.path.join(conf_dir,'proton.sasldb'))
+ conf = os.path.abspath(os.path.join(conf_dir,'proton.conf'))
+ f = open(conf, 'w')
+ f.write(t.substitute(db=db))
+ f.close()
+
+ cmd = Template("echo password | saslpasswd2 -c -p -f ${db} -u proton user").substitute(db=db)
+ subprocess.call(args=cmd, shell=True)
+
+def _testSaslMech(self, mech, clientUser='user@proton', authUser='user@proton', encrypted=False, authenticated=True):
+ self.s1.allowed_mechs(mech)
+ self.c1.open()
+
+ pump(self.t1, self.t2, 1024)
+
+ if encrypted:
+ assert self.t2.encrypted == encrypted
+ assert self.t1.encrypted == encrypted
+ assert self.t2.authenticated == authenticated
+ assert self.t1.authenticated == authenticated
+ if authenticated:
+ # Server
+ assert self.t2.user == authUser
+ assert self.s2.user == authUser
+ assert self.s2.mech == mech.strip()
+ assert self.s2.outcome == SASL.OK
+ # Client
+ assert self.t1.user == clientUser
+ assert self.s1.user == clientUser
+ assert self.s1.mech == mech.strip()
+ assert self.s1.outcome == SASL.OK
+ else:
+ # Server
+ assert self.t2.user == None
+ assert self.s2.user == None
+ assert self.s2.outcome != SASL.OK
+ # Client
+ assert self.t1.user == clientUser
+ assert self.s1.user == clientUser
+ assert self.s1.outcome != SASL.OK
+
class Test(common.Test):
pass
@@ -32,6 +92,13 @@ class SaslTest(Test):
self.t2 = Transport(Transport.SERVER)
self.s2 = SASL(self.t2)
+ if not SASL.extended():
+ return
+
+ _cyrusSetup('sasl_conf')
+ self.s2.config_name('proton')
+ self.s2.config_path(os.path.abspath('sasl_conf'))
+
def pump(self):
pump(self.t1, self.t2, 1024)
@@ -215,11 +282,11 @@ class SaslTest(Test):
self.t2.require_auth(False)
self.pump()
assert self.s2.outcome == None
- self.t2.condition == None
- self.t2.authenticated == False
+ assert self.t2.condition == None
+ assert self.t2.authenticated == False
assert self.s1.outcome == None
- self.t1.condition == None
- self.t1.authenticated == False
+ assert self.t1.condition == None
+ assert self.t1.authenticated == False
def testSaslSkippedFail(self):
"""Verify that the server (with SASL) correctly handles a client without SASL"""
@@ -227,6 +294,175 @@ class SaslTest(Test):
self.t2.require_auth(True)
self.pump()
assert self.s2.outcome == None
- self.t2.condition != None
+ assert self.t2.condition != None
assert self.s1.outcome == None
- self.t1.condition != None
+ assert self.t1.condition != None
+
+ def testMechNotFound(self):
+ if "java" in sys.platform:
+ raise Skipped("Proton-J does not support checking authentication state")
+ self.c1 = Connection()
+ self.c1.open()
+ self.t1.bind(self.c1)
+ self.s1.allowed_mechs('IMPOSSIBLE')
+
+ self.pump()
+
+ assert self.t2.authenticated == False
+ assert self.t1.authenticated == False
+ assert self.s1.outcome != SASL.OK
+ assert self.s2.outcome != SASL.OK
+
+class CyrusSASLTest(Test):
+ def setup(self):
+ self.t1 = Transport()
+ self.s1 = SASL(self.t1)
+ self.t2 = Transport(Transport.SERVER)
+ self.s2 = SASL(self.t2)
+
+ self.c1 = Connection()
+ self.c1.user = 'user@proton'
+ self.c1.password = 'password'
+ self.c1.hostname = 'localhost'
+
+ if not SASL.extended():
+ return
+
+ _cyrusSetup('sasl_conf')
+ self.s2.config_name('proton')
+ self.s2.config_path(os.path.abspath('sasl_conf'))
+
+ def testMechANON(self):
+ self.t1.bind(self.c1)
+ _testSaslMech(self, 'ANONYMOUS', authUser='anonymous')
+
+ def testMechCRAMMD5(self):
+ if not SASL.extended():
+ raise Skipped('Extended SASL not supported')
+
+ self.t1.bind(self.c1)
+ _testSaslMech(self, 'CRAM-MD5')
+
+ def testMechDIGESTMD5(self):
+ if not SASL.extended():
+ raise Skipped('Extended SASL not supported')
+
+ self.t1.bind(self.c1)
+ _testSaslMech(self, 'DIGEST-MD5')
+
+# SCRAM not supported before Cyrus SASL 2.1.26
+# so not universal and hance need a test for support
+# to keep it in tests.
+# def testMechSCRAMSHA1(self):
+# if not SASL.extended():
+# raise Skipped('Extended SASL not supported')
+#
+# self.t1.bind(self.c1)
+# _testSaslMech(self, 'SCRAM-SHA-1')
+
+def _sslConnection(domain, transport, connection):
+ transport.bind(connection)
+ ssl = SSL(transport, domain, None )
+ return connection
+
+class SSLSASLTest(Test):
+ def setup(self):
+ if not common.isSSLPresent():
+ raise Skipped("No SSL libraries found.")
+
+ self.server_domain = SSLDomain(SSLDomain.MODE_SERVER)
+ self.client_domain = SSLDomain(SSLDomain.MODE_CLIENT)
+
+ self.t1 = Transport()
+ self.s1 = SASL(self.t1)
+ self.t2 = Transport(Transport.SERVER)
+ self.s2 = SASL(self.t2)
+
+ self.c1 = Connection()
+
+ if not SASL.extended():
+ return
+
+ _cyrusSetup('sasl_conf')
+ self.s2.config_name('proton')
+ self.s2.config_path(os.path.abspath('sasl_conf'))
+
+ def testSSLPlainSimple(self):
+ if "java" in sys.platform:
+ raise Skipped("Proton-J does not support SSL with SASL")
+ if not SASL.extended():
+ raise Skipped("Simple SASL server does not support PLAIN")
+
+ clientUser = 'user@proton'
+ mech = 'PLAIN'
+
+ self.c1.user = clientUser
+ self.c1.password = 'password'
+ self.c1.hostname = 'localhost'
+
+ ssl1 = _sslConnection(self.client_domain, self.t1, self.c1)
+ ssl2 = _sslConnection(self.server_domain, self.t2, Connection())
+
+ _testSaslMech(self, mech, encrypted=True)
+
+ def testSSLPlainSimpleFail(self):
+ if "java" in sys.platform:
+ raise Skipped("Proton-J does not support SSL with SASL")
+ if not SASL.extended():
+ raise Skipped("Simple SASL server does not support PLAIN")
+
+ clientUser = 'usr@proton'
+ mech = 'PLAIN'
+
+ self.c1.user = clientUser
+ self.c1.password = 'password'
+ self.c1.hostname = 'localhost'
+
+ ssl1 = _sslConnection(self.client_domain, self.t1, self.c1)
+ ssl2 = _sslConnection(self.server_domain, self.t2, Connection())
+
+ _testSaslMech(self, mech, clientUser='usr@proton', encrypted=True, authenticated=False)
+
+ def testSSLExternalSimple(self):
+ if "java" in sys.platform:
+ raise Skipped("Proton-J does not support SSL with SASL")
+
+ extUser = 'O=Client,CN=127.0.0.1'
+ mech = 'EXTERNAL'
+
+ self.server_domain.set_credentials(_sslCertpath("server-certificate.pem"),
+ _sslCertpath("server-private-key.pem"),
+ "server-password")
+ self.server_domain.set_trusted_ca_db(_sslCertpath("ca-certificate.pem"))
+ self.server_domain.set_peer_authentication(SSLDomain.VERIFY_PEER,
+ _sslCertpath("ca-certificate.pem") )
+ self.client_domain.set_credentials(_sslCertpath("client-certificate.pem"),
+ _sslCertpath("client-private-key.pem"),
+ "client-password")
+ self.client_domain.set_trusted_ca_db(_sslCertpath("ca-certificate.pem"))
+ self.client_domain.set_peer_authentication(SSLDomain.VERIFY_PEER)
+
+ ssl1 = _sslConnection(self.client_domain, self.t1, self.c1)
+ ssl2 = _sslConnection(self.server_domain, self.t2, Connection())
+
+ _testSaslMech(self, mech, clientUser=None, authUser=extUser, encrypted=True)
+
+ def testSSLExternalSimpleFail(self):
+ if "java" in sys.platform:
+ raise Skipped("Proton-J does not support SSL with SASL")
+
+ mech = 'EXTERNAL'
+
+ self.server_domain.set_credentials(_sslCertpath("server-certificate.pem"),
+ _sslCertpath("server-private-key.pem"),
+ "server-password")
+ self.server_domain.set_trusted_ca_db(_sslCertpath("ca-certificate.pem"))
+ self.server_domain.set_peer_authentication(SSLDomain.VERIFY_PEER,
+ _sslCertpath("ca-certificate.pem") )
+ self.client_domain.set_trusted_ca_db(_sslCertpath("ca-certificate.pem"))
+ self.client_domain.set_peer_authentication(SSLDomain.VERIFY_PEER)
+
+ ssl1 = _sslConnection(self.client_domain, self.t1, self.c1)
+ ssl2 = _sslConnection(self.server_domain, self.t2, Connection())
+
+ _testSaslMech(self, mech, clientUser=None, authUser=None, encrypted=None, authenticated=False)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[41/50] qpid-proton git commit: PROTON-781: Added
SessionPerConnection to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added SessionPerConnection to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e593ba84
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e593ba84
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e593ba84
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: e593ba8469fa72a72163e663f147baa0ac4506ff
Parents: 0910020
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 16:40:01 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
.../ruby/lib/reactor/session_per_connection.rb | 45 ++++++++++++++++++++
2 files changed, 46 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e593ba84/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 661927e..f40c608 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -105,6 +105,7 @@ require "reactor/global_overrides"
require "reactor/urls"
require "reactor/connector"
require "reactor/backoff"
+require "reactor/session_per_connection"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e593ba84/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb b/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb
new file mode 100644
index 0000000..f8180c0
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb
@@ -0,0 +1,45 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class SessionPerConnection
+
+ include Qpid::Proton::Util::Reactor
+
+ def initialize
+ @default_session = nil
+ end
+
+ def session(connection)
+ if @default_session.nil?
+ @default_session = self.create_session
+ @default_session.context = self
+ end
+ return @default_session
+ end
+
+ def on_session_remote_close(event)
+ event.connection.close
+ @default_session = nil
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[10/50] qpid-proton git commit: PROTON-909: Rearrange the test code
to create the Cyrus SASL configuration - Make the Cyrus SASL configuration
global for all the testing - This fixes test failures against earlier
versions of the Cyrus library - The bug t
Posted by mc...@apache.org.
PROTON-909: Rearrange the test code to create the Cyrus SASL configuration
- Make the Cyrus SASL configuration global for all the testing
- This fixes test failures against earlier versions of the Cyrus library
- The bug this fixes relates to PROTON-862
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0f90a7e4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0f90a7e4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0f90a7e4
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 0f90a7e4c9cc5a1decd7f6896c16d9b8b0653316
Parents: 56af118
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Jun 16 14:25:16 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Jun 16 14:54:13 2015 -0400
----------------------------------------------------------------------
tests/python/proton_tests/common.py | 28 +++++++++++++++++++++-
tests/python/proton_tests/sasl.py | 40 --------------------------------
2 files changed, 27 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f90a7e4/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 83a39f8..11bea85 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -22,10 +22,11 @@ from random import randint
from threading import Thread
from socket import socket, AF_INET, SOCK_STREAM
from subprocess import Popen,PIPE,STDOUT
-import sys, os, string
+import sys, os, string, subprocess
from proton import Connection, Transport, SASL, Endpoint, Delivery, SSL
from proton.reactor import Container
from proton.handlers import CHandshaker, CFlowController
+from string import Template
def free_tcp_ports(count=1):
@@ -86,6 +87,31 @@ def pump(transport1, transport2, buffer_size=1024):
def isSSLPresent():
return SSL.present()
+def _cyrusSetup(conf_dir):
+ """Write out simple SASL config.
+ This assumes saslpasswd2 is in the OS path.
+ """
+ t = Template("""sasldb_path: ${db}
+mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
+""")
+ abs_conf_dir = os.path.abspath(conf_dir)
+ subprocess.call(args=['rm','-rf',abs_conf_dir])
+ os.mkdir(abs_conf_dir)
+ db = os.path.join(abs_conf_dir,'proton.sasldb')
+ conf = os.path.join(abs_conf_dir,'proton-server.conf')
+ f = open(conf, 'w')
+ f.write(t.substitute(db=db))
+ f.close()
+
+ cmd = Template("echo password | saslpasswd2 -c -p -f ${db} -u proton user").substitute(db=db)
+ subprocess.call(args=cmd, shell=True)
+
+ os.environ['PN_SASL_CONFIG_PATH'] = abs_conf_dir
+
+# Globally initialize Cyrus SASL configuration
+if SASL.extended():
+ _cyrusSetup('sasl_conf')
+
class Test(TestCase):
def __init__(self, name):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f90a7e4/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 91b3e69..7f1e7ad 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -18,8 +18,6 @@
#
import sys, os, common
-from string import Template
-import subprocess
from proton import *
from common import pump, Skipped
@@ -32,23 +30,6 @@ def _sslCertpath(file):
return os.path.join(os.path.dirname(__file__),
"ssl_db/%s" % file)
-def _cyrusSetup(conf_dir):
- """Write out simple SASL config
- """
- t = Template("""sasldb_path: ${db}
-mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
-""")
- subprocess.call(args=['rm','-rf',conf_dir])
- os.mkdir(conf_dir)
- db = os.path.abspath(os.path.join(conf_dir,'proton.sasldb'))
- conf = os.path.abspath(os.path.join(conf_dir,'proton.conf'))
- f = open(conf, 'w')
- f.write(t.substitute(db=db))
- f.close()
-
- cmd = Template("echo password | saslpasswd2 -c -p -f ${db} -u proton user").substitute(db=db)
- subprocess.call(args=cmd, shell=True)
-
def _testSaslMech(self, mech, clientUser='user@proton', authUser='user@proton', encrypted=False, authenticated=True):
self.s1.allowed_mechs(mech)
self.c1.open()
@@ -92,13 +73,6 @@ class SaslTest(Test):
self.t2 = Transport(Transport.SERVER)
self.s2 = SASL(self.t2)
- if not SASL.extended():
- return
-
- _cyrusSetup('sasl_conf')
- self.s2.config_name('proton')
- self.s2.config_path(os.path.abspath('sasl_conf'))
-
def pump(self):
pump(self.t1, self.t2, 1024)
@@ -325,13 +299,6 @@ class CyrusSASLTest(Test):
self.c1.password = 'password'
self.c1.hostname = 'localhost'
- if not SASL.extended():
- return
-
- _cyrusSetup('sasl_conf')
- self.s2.config_name('proton')
- self.s2.config_path(os.path.abspath('sasl_conf'))
-
def testMechANON(self):
self.t1.bind(self.c1)
_testSaslMech(self, 'ANONYMOUS', authUser='anonymous')
@@ -380,13 +347,6 @@ class SSLSASLTest(Test):
self.c1 = Connection()
- if not SASL.extended():
- return
-
- _cyrusSetup('sasl_conf')
- self.s2.config_name('proton')
- self.s2.config_path(os.path.abspath('sasl_conf'))
-
def testSSLPlainSimple(self):
if "java" in sys.platform:
raise Skipped("Proton-J does not support SSL with SASL")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[12/50] qpid-proton git commit: PROTON-917: avoid buffer underrun if
no mechs given
Posted by mc...@apache.org.
PROTON-917: avoid buffer underrun if no mechs given
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/718d8b37
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/718d8b37
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/718d8b37
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 718d8b37644ab9102364ce8e23ee47b029191556
Parents: cbb6800
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Jun 17 14:47:29 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Jun 17 14:49:58 2015 -0400
----------------------------------------------------------------------
proton-c/src/sasl/sasl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/718d8b37/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index 3142832..c339ea9 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -586,7 +586,10 @@ int pn_do_mechanisms(pn_transport_t *transport, uint8_t frame_type, uint16_t cha
pn_string_addf(mechs, "%*s ", (int)s.size, s.start);
}
}
- pn_string_buffer(mechs)[pn_string_size(mechs)-1] = 0;
+
+ if (pn_string_size(mechs)) {
+ pn_string_buffer(mechs)[pn_string_size(mechs)-1] = 0;
+ }
if (pni_init_client(transport) &&
pni_process_mechanisms(transport, pn_string_get(mechs))) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[43/50] qpid-proton git commit: PROTON-781: Added the URL class to
the Ruby core APIs.
Posted by mc...@apache.org.
PROTON-781: Added the URL class to the Ruby core APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/afd25a61
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/afd25a61
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/afd25a61
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: afd25a612268ae7d891bb25dc4d831bdc52331f3
Parents: ac46b78
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 16:36:39 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/url.rb | 77 ++++++++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 78 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/afd25a61/proton-c/bindings/ruby/lib/core/url.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/url.rb b/proton-c/bindings/ruby/lib/core/url.rb
new file mode 100644
index 0000000..a68811a
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -0,0 +1,77 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton
+
+ class URL
+
+ attr_reader :scheme
+ attr_reader :username
+ attr_reader :password
+ attr_reader :host
+ attr_reader :port
+ attr_reader :path
+
+ def initialize(url = nil, options = {})
+ options[:defaults] = true
+
+ if url
+ @url = Cproton.pn_url_parse(url)
+ if @url.nil?
+ raise ArgumentError.new("invalid url: #{url}")
+ end
+ else
+ @url = Cproton.pn_url
+ end
+ @scheme = Cproton.pn_url_get_scheme(@url)
+ @username = Cproton.pn_url_get_username(@url)
+ @password = Cproton.pn_url_get_password(@url)
+ @host = Cproton.pn_url_get_host(@url)
+ @port = Cproton.pn_url_get_port(@url)
+ @path = Cproton.pn_url_get_path(@url)
+ defaults
+ end
+
+ def port=(port)
+ if port.nil?
+ Cproton.pn_url_set_port(@url, nil)
+ else
+ Cproton.pn_url_set_port(@url, port)
+ end
+ end
+
+ def port
+ Cproton.pn_url_get_port(@url).to_i
+ end
+
+ def to_s
+ "#{@scheme}://#{@username.nil? ? '' : @username}#{@password.nil? ? '' : '@' + @password + ':'}#{@host}:#{@port}/#{@path}"
+ end
+
+ private
+
+ def defaults
+ @scheme = @scheme || "ampq"
+ @host = @host || "0.0.0.0"
+ @port = @port || 5672
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/afd25a61/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 33fe9b6..11a555f 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -78,6 +78,7 @@ require "core/ssl_details"
require "core/ssl"
require "core/transport"
require "core/base_handler"
+require "core/url"
# Messenger API classes
require "messenger/subscription"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[18/50] qpid-proton git commit: PROTON-842: enforce channel_max limit
on session creation
Posted by mc...@apache.org.
PROTON-842: enforce channel_max limit on session creation
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e38957ae
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e38957ae
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e38957ae
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: e38957ae5115ec023993672ca5b7d5e3df414f7e
Parents: 175a15a
Author: Mick Goulish <mi...@redhat.com>
Authored: Thu Jun 18 08:45:47 2015 -0400
Committer: Mick Goulish <mi...@redhat.com>
Committed: Thu Jun 18 08:45:47 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 7 +-
proton-c/include/proton/cproton.i | 2 -
proton-c/include/proton/transport.h | 16 +++-
proton-c/src/engine/engine-internal.h | 14 ++-
proton-c/src/engine/engine.c | 16 +++-
proton-c/src/transport/transport.c | 111 ++++++++++++++++++++---
tests/python/proton_tests/engine.py | 44 ++++++++-
7 files changed, 191 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index 9432bd8..5860764 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -2484,7 +2484,11 @@ class Connection(Wrapper, Endpoint):
"""
Returns a new session on this connection.
"""
- return Session(pn_session(self._impl))
+ ssn = pn_session(self._impl)
+ if ssn is None:
+ raise(SessionException("Session allocation failed."))
+ else:
+ return Session(ssn)
def session_head(self, mask):
return Session.wrap(pn_session_head(self._impl, mask))
@@ -3987,6 +3991,7 @@ __all__ = [
"SASL",
"Sender",
"Session",
+ "SessionException",
"SSL",
"SSLDomain",
"SSLSessionDetails",
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/include/proton/cproton.i
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/cproton.i b/proton-c/include/proton/cproton.i
index ac2b121..b55211f 100644
--- a/proton-c/include/proton/cproton.i
+++ b/proton-c/include/proton/cproton.i
@@ -210,8 +210,6 @@ typedef unsigned long int uintptr_t;
{
require:
connection != NULL;
- ensure:
- pn_session != NULL;
}
%contract pn_transport(pn_connection_t *connection)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/include/proton/transport.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/transport.h b/proton-c/include/proton/transport.h
index a3ca667..483f5a9 100644
--- a/proton-c/include/proton/transport.h
+++ b/proton-c/include/proton/transport.h
@@ -320,6 +320,10 @@ PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ...
/**
* Get the maximum allowed channel for a transport.
+ * This will be the minimum of
+ * 1. limit imposed by this proton implementation
+ * 2. limit imposed by remote peer
+ * 3. limit imposed by this application, using pn_transport_set_channel_max()
*
* @param[in] transport a transport object
* @return the maximum allowed channel
@@ -327,7 +331,17 @@ PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ...
PN_EXTERN uint16_t pn_transport_get_channel_max(pn_transport_t *transport);
/**
- * Set the maximum allowed channel for a transport.
+ * Set the maximum allowed channel number for a transport.
+ * Note that this is the maximum channel number allowed, giving a
+ * valid channel number range of [0..channel_max]. Therefore the
+ * maximum number of simultaineously active channels will be
+ * channel_max plus 1.
+ * You can call this function more than once to raise and lower
+ * the limit your application imposes on max channels for this
+ * transport. However, smaller limits may be imposed by this
+ * library, or by the remote peer.
+ * After the OPEN frame has been sent to the remote peer,
+ * further calls to this function will have no effect.
*
* @param[in] transport a transport object
* @param[in] channel_max the maximum allowed channel
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/src/engine/engine-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/engine/engine-internal.h b/proton-c/src/engine/engine-internal.h
index 4c72310..c03a0a3 100644
--- a/proton-c/src/engine/engine-internal.h
+++ b/proton-c/src/engine/engine-internal.h
@@ -178,8 +178,20 @@ struct pn_transport_t {
pn_trace_t trace;
- uint16_t channel_max;
+ /*
+ * The maximum channel number can be constrained in several ways:
+ * 1. an unchangeable limit imposed by this library code
+ * 2. a limit imposed by the remote peer when the connection is opened,
+ * which this app must honor
+ * 3. a limit imposed by this app, which may be raised and lowered
+ * until the OPEN frame is sent.
+ * These constraints are all summed up in channel_max, below.
+ */
+ #define PN_IMPL_CHANNEL_MAX 32767
+ uint16_t local_channel_max;
uint16_t remote_channel_max;
+ uint16_t channel_max;
+
bool freed;
bool open_sent;
bool open_rcvd;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/src/engine/engine.c
----------------------------------------------------------------------
diff --git a/proton-c/src/engine/engine.c b/proton-c/src/engine/engine.c
index c5228a5..936cf60 100644
--- a/proton-c/src/engine/engine.c
+++ b/proton-c/src/engine/engine.c
@@ -953,12 +953,26 @@ static void pn_session_finalize(void *object)
pn_session_t *pn_session(pn_connection_t *conn)
{
assert(conn);
+
+
+ pn_transport_t * transport = pn_connection_transport(conn);
+
+ if(transport) {
+ // channel_max is an index, not a count.
+ if(pn_hash_size(transport->local_channels) > (size_t)transport->channel_max) {
+ pn_transport_logf(transport,
+ "pn_session: too many sessions: %d channel_max is %d",
+ pn_hash_size(transport->local_channels),
+ transport->channel_max);
+ return (pn_session_t *) 0;
+ }
+ }
+
#define pn_session_free pn_object_free
static const pn_class_t clazz = PN_METACLASS(pn_session);
#undef pn_session_free
pn_session_t *ssn = (pn_session_t *) pn_class_new(&clazz, sizeof(pn_session_t));
if (!ssn) return NULL;
-
pn_endpoint_init(&ssn->endpoint, SESSION, conn);
pni_add_session(conn, ssn);
ssn->links = pn_list(PN_WEAKREF, 0);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index 733f695..ff80e21 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -43,6 +43,33 @@ static ssize_t transport_consume(pn_transport_t *transport);
// delivery buffers
+/*
+ * Call this any time anything happens that may affect channel_max:
+ * i.e. when the app indicates a preference, or when we receive the
+ * OPEN frame from the remote peer. And call it to do the final
+ * calculation just before we communicate our limit to the remote
+ * peer by sending our OPEN frame.
+ */
+static void pni_calculate_channel_max(pn_transport_t *transport) {
+ /*
+ * The application cannot make the limit larger than
+ * what this library will allow.
+ */
+ transport->channel_max = (PN_IMPL_CHANNEL_MAX < transport->local_channel_max)
+ ? PN_IMPL_CHANNEL_MAX
+ : transport->local_channel_max;
+
+ /*
+ * The remote peer's constraint is not valid until the
+ * peer's open frame has been received.
+ */
+ if(transport->open_rcvd) {
+ transport->channel_max = (transport->channel_max < transport->remote_channel_max)
+ ? transport->channel_max
+ : transport->remote_channel_max;
+ }
+}
+
void pn_delivery_map_init(pn_delivery_map_t *db, pn_sequence_t next)
{
db->deliveries = pn_hash(PN_WEAKREF, 0, 0.75);
@@ -370,7 +397,23 @@ static void pn_transport_initialize(void *object)
transport->remote_hostname = NULL;
transport->local_max_frame = PN_DEFAULT_MAX_FRAME_SIZE;
transport->remote_max_frame = 0;
- transport->channel_max = 0;
+
+ /*
+ * We set the local limit on channels to 2^15, because
+ * parts of the code use the topmost bit (of a short)
+ * as a flag.
+ * The peer that this transport connects to may also
+ * place its own limit on max channel number, and the
+ * application may also set a limit.
+ * The maximum that we use will be the minimum of all
+ * these constraints.
+ */
+ // There is no constraint yet from remote peer,
+ // so set to max possible.
+ transport->remote_channel_max = 65535;
+ transport->local_channel_max = PN_IMPL_CHANNEL_MAX;
+ transport->channel_max = transport->local_channel_max;
+
transport->remote_channel_max = 0;
transport->local_idle_timeout = 0;
transport->dead_remote_deadline = 0;
@@ -1098,6 +1141,7 @@ int pn_do_open(pn_transport_t *transport, uint8_t frame_type, uint16_t channel,
transport->halt = true;
}
transport->open_rcvd = true;
+ pni_calculate_channel_max(transport);
return 0;
}
@@ -1109,6 +1153,18 @@ int pn_do_begin(pn_transport_t *transport, uint8_t frame_type, uint16_t channel,
int err = pn_data_scan(args, "D.[?HI]", &reply, &remote_channel, &next);
if (err) return err;
+ // AMQP 1.0 section 2.7.1 - if the peer doesn't honor our channel_max --
+ // express our displeasure by closing the connection with a framing error.
+ if (remote_channel > transport->channel_max) {
+ pn_do_error(transport,
+ "amqp:connection:framing-error",
+ "remote channel %d is above negotiated channel_max %d.",
+ remote_channel,
+ transport->channel_max
+ );
+ return PN_TRANSPORT_ERROR;
+ }
+
pn_session_t *ssn;
if (reply) {
// XXX: what if session is NULL?
@@ -1774,6 +1830,7 @@ static int pni_process_conn_setup(pn_transport_t *transport, pn_endpoint_t *endp
: 0;
pn_connection_t *connection = (pn_connection_t *) endpoint;
const char *cid = pn_string_get(connection->container);
+ pni_calculate_channel_max(transport);
int err = pn_post_frame(transport, AMQP_FRAME_TYPE, 0, "DL[SS?I?H?InnCCC]", OPEN,
cid ? cid : "",
pn_string_get(connection->hostname),
@@ -1792,15 +1849,16 @@ static int pni_process_conn_setup(pn_transport_t *transport, pn_endpoint_t *endp
return 0;
}
-static uint16_t allocate_alias(pn_hash_t *aliases)
+static uint16_t allocate_alias(pn_hash_t *aliases, uint32_t max_index, int * valid)
{
- for (uint32_t i = 0; i < 65536; i++) {
+ for (uint32_t i = 0; i <= max_index; i++) {
if (!pn_hash_get(aliases, i)) {
+ * valid = 1;
return i;
}
}
- assert(false);
+ * valid = 0;
return 0;
}
@@ -1828,14 +1886,19 @@ static size_t pni_session_incoming_window(pn_session_t *ssn)
}
}
-static void pni_map_local_channel(pn_session_t *ssn)
+static int pni_map_local_channel(pn_session_t *ssn)
{
pn_transport_t *transport = ssn->connection->transport;
pn_session_state_t *state = &ssn->state;
- uint16_t channel = allocate_alias(transport->local_channels);
+ int valid;
+ uint16_t channel = allocate_alias(transport->local_channels, transport->channel_max, & valid);
+ if (!valid) {
+ return 0;
+ }
state->local_channel = channel;
pn_hash_put(transport->local_channels, channel, ssn);
pn_ep_incref(&ssn->endpoint);
+ return 1;
}
static int pni_process_ssn_setup(pn_transport_t *transport, pn_endpoint_t *endpoint)
@@ -1846,7 +1909,10 @@ static int pni_process_ssn_setup(pn_transport_t *transport, pn_endpoint_t *endpo
pn_session_state_t *state = &ssn->state;
if (!(endpoint->state & PN_LOCAL_UNINIT) && state->local_channel == (uint16_t) -1)
{
- pni_map_local_channel(ssn);
+ if (! pni_map_local_channel(ssn)) {
+ pn_transport_logf(transport, "unable to find an open available channel within limit of %d", transport->channel_max );
+ return PN_ERR;
+ }
state->incoming_window = pni_session_incoming_window(ssn);
state->outgoing_window = pni_session_outgoing_window(ssn);
pn_post_frame(transport, AMQP_FRAME_TYPE, state->local_channel, "DL[?HIII]", BEGIN,
@@ -1876,12 +1942,17 @@ static const char *expiry_symbol(pn_expiry_policy_t policy)
return NULL;
}
-static void pni_map_local_handle(pn_link_t *link) {
+static int pni_map_local_handle(pn_link_t *link) {
pn_link_state_t *state = &link->state;
pn_session_state_t *ssn_state = &link->session->state;
- state->local_handle = allocate_alias(ssn_state->local_handles);
+ int valid;
+ // XXX TODO MICK: once changes are made to handle_max, change this hardcoded value to something reasonable.
+ state->local_handle = allocate_alias(ssn_state->local_handles, 65536, & valid);
+ if ( ! valid )
+ return 0;
pn_hash_put(ssn_state->local_handles, state->local_handle, link);
pn_ep_incref(&link->endpoint);
+ return 1;
}
static int pni_process_link_setup(pn_transport_t *transport, pn_endpoint_t *endpoint)
@@ -2574,9 +2645,27 @@ uint16_t pn_transport_get_channel_max(pn_transport_t *transport)
return transport->channel_max;
}
-void pn_transport_set_channel_max(pn_transport_t *transport, uint16_t channel_max)
+void pn_transport_set_channel_max(pn_transport_t *transport, uint16_t requested_channel_max)
{
- transport->channel_max = channel_max;
+ /*
+ * Once the OPEN frame has been sent, we have communicated our
+ * wishes to the remote client and there is no way to renegotiate.
+ * After that point, we do not allow the application to make changes.
+ * Before that point, however, the app is free to either raise or
+ * lower our local limit. (But the app cannot raise it above the
+ * limit imposed by this library.)
+ * The channel-max value will be finalized just before the OPEN frame
+ * is sent.
+ */
+ if(transport->open_sent) {
+ pn_transport_logf(transport, "Cannot change local channel-max after OPEN frame sent.");
+ }
+ else {
+ transport->local_channel_max = (requested_channel_max < PN_IMPL_CHANNEL_MAX)
+ ? requested_channel_max
+ : PN_IMPL_CHANNEL_MAX;
+ pni_calculate_channel_max(transport);
+ }
}
uint16_t pn_transport_remote_channel_max(pn_transport_t *transport)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 924b3bc..1563889 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -211,11 +211,51 @@ class ConnectionTest(Test):
assert self.c2.remote_properties == p1, (self.c2.remote_properties, p1)
assert self.c1.remote_properties == p2, (self.c2.remote_properties, p2)
- def test_channel_max(self, value=1234):
+ # The proton implementation limits channel_max to 32767.
+ # If I set the application's limit lower than that, I should
+ # get my wish. If I set it higher -- not.
+ def test_channel_max_low(self, value=1234):
self.c1.transport.channel_max = value
self.c1.open()
self.pump()
- assert self.c2.transport.remote_channel_max == value, (self.c2.transport.remote_channel_max, value)
+ assert self.c1.transport.channel_max == value, (self.c1.transport.channel_max, value)
+
+ def test_channel_max_high(self, value=33333):
+ self.c1.transport.channel_max = value
+ self.c1.open()
+ self.pump()
+ assert self.c1.transport.channel_max == 32767, (self.c1.transport.channel_max, value)
+
+ def test_channel_max_raise_and_lower(self):
+ # It's OK to lower the max below 32767.
+ self.c1.transport.channel_max = 12345
+ assert self.c1.transport.channel_max == 12345
+ # But it won't let us raise the limit above 32767.
+ self.c1.transport.channel_max = 33333
+ assert self.c1.transport.channel_max == 32767
+ self.c1.open()
+ self.pump()
+ # Now it's too late to make any change, because
+ # we have already sent the OPEN frame.
+ self.c1.transport.channel_max = 666
+ assert self.c1.transport.channel_max == 32767
+
+
+ def test_channel_max_limits_sessions(self):
+ return
+ # This is an index -- so max number of channels should be 1.
+ self.c1.transport.channel_max = 0
+ self.c1.open()
+ self.c2.open()
+ ssn_0 = self.c2.session()
+ assert ssn_0 != None
+ ssn_0.open()
+ self.pump()
+ try:
+ ssn_1 = self.c2.session()
+ assert False, "expected session exception"
+ except SessionException:
+ pass
def test_cleanup(self):
self.c1.open()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[21/50] qpid-proton git commit: PROTON-781: Refactored the Ruby
Selectable class.
Posted by mc...@apache.org.
PROTON-781: Refactored the Ruby Selectable class.
It now more closely matches the Python version.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/51e85ea5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/51e85ea5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/51e85ea5
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 51e85ea53a0437a623a287a4ecce38b87e190e82
Parents: 9454f50
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Jun 4 13:56:49 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:19 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/selectable.rb | 124 +++++++++++----------
1 file changed, 68 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/51e85ea5/proton-c/bindings/ruby/lib/core/selectable.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/selectable.rb b/proton-c/bindings/ruby/lib/core/selectable.rb
index 8a5b223..0ae2efe 100644
--- a/proton-c/bindings/ruby/lib/core/selectable.rb
+++ b/proton-c/bindings/ruby/lib/core/selectable.rb
@@ -25,13 +25,11 @@ module Qpid::Proton
# @private
class Selectable
+ # @private
+ include Util::SwigHelper
- def initialize(messenger, impl) # :nodoc:
- @messenger = messenger
- @impl = impl
- @io = nil
- @freed = false
- end
+ # @private
+ PROTON_METHOD_PREFIX = "pn_selectable"
# Returns the underlying file descriptor.
#
@@ -41,76 +39,90 @@ module Qpid::Proton
Cproton.pn_selectable_get_fd(@impl)
end
- def to_io
- @io ||= IO.new(fileno)
- end
+ proton_reader :reading, :is_or_get => :is
- # The number of bytes the selectable is capable of consuming.
- #
- #def capacity
- # Cproton.pn_selectable_capacity(@impl)
- #end
+ proton_reader :writing, :is_or_get => :is
- # The number of bytes waiting to be written to the file descriptor.
- #
- def pending
- Cproton.pn_selectable_pending(@impl)
- end
+ proton_caller :readable
- # The future expiry time at which control will be returned to the
- # selectable.
- #
- def deadline
- tstamp = Cproton.pn_selectable_deadline(@impl)
- tstamp.nil? ? nil : tstamp / 1000
- end
+ proton_caller :writable
- def readable
- Cproton.pn_selectable_readable(@impl)
- end
+ proton_caller :expired
- def writable
- Cproton.pn_selectable_writable(@impl)
- end
+ proton_accessor :registered, :is_or_get => :is
- def expired?
- Cproton.pn_selectable_expired(@impl)
- end
+ proton_accessor :terminal, :is_or_get => :is
- def registered=(registered)
- Cproton.pn_selectable_set_registered(@impl, registered)
+ proton_caller :terminate
+
+ proton_caller :release
+
+ # @private
+ def self.wrap(impl)
+ return nil if impl.nil?
+
+ self.fetch_instance(impl, :pn_selectable_attachments) || Selectable.new(impl)
end
- def registered?
- Cproton.pn_selectable_is_registered(@impl)
+ # @private
+ include Util::Wrapper
+
+ # @private
+ def initialize(impl)
+ @impl = impl
+ self.class.store_instance(self, :pn_selectable_attachments)
end
- def terminal?
- return true if @impl.nil?
- Cproton.pn_selectable_is_terminal(@impl)
+ private
+
+ DEFAULT = Object.new
+
+ public
+
+ def fileno(fd = DEFAULT)
+ if fd == DEFAULT
+ Cproton.pn_selectable_get_fd(@impl)
+ elsif fd.nil?
+ Cproton.pn_selectable_set_fd(@impl, Cproton::PN_INVALID_SOCKET)
+ else
+ Cproton.pn_selectable_set_fd(@impl, fd)
+ end
end
- def to_s
- "fileno=#{self.fileno} registered=#{self.registered?} terminal=#{self.terminal?}"
+ def reading=(reading)
+ if reading.nil?
+ reading = false
+ elsif reading == "0"
+ reading = false
+ else
+ reading = true
+ end
+ Cproton.pn_selectable_set_reading(@impl, reading ? true : false)
end
- def free
- return if @freed
- @freed = true
- @messenger.unregister_selectable(fileno)
- @io.close unless @io.nil?
- Cproton.pn_selectable_free(@impl)
- @impl = nil
+ def writing=(writing)
+ if writing.nil?
+ writing = false
+ elsif writing == "0"
+ writing = false
+ else
+ writing = true
+ end
+ Cproton.pn_selectable_set_writing(@impl, writing ? true : false)
end
- def freed? # :nodoc:
- @freed
+ def deadline
+ tstamp = Cproton.pn_selectable_get_deadline(@impl)
+ return nil if tstamp.nil?
+ mills_to_sec(tstamp)
end
- private
+ def deadline=(deadline)
+ Cproton.pn_selectable_set_deadline(sec_to_millis(deadline))
+ end
- def check_is_initialized
- raise RuntimeError.new("selectable freed") if @impl.nil?
+ def to_io
+ @io ||= IO.new(fileno)
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[03/50] qpid-proton git commit: NO-JIRA: Add in SASL pieces to Travis
CI build
Posted by mc...@apache.org.
NO-JIRA: Add in SASL pieces to Travis CI build
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e55fe323
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e55fe323
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e55fe323
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: e55fe323e08f4ac3a8f51d055cae7eb460b96018
Parents: d7df576
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Jun 3 16:47:51 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Jun 11 16:20:28 2015 -0400
----------------------------------------------------------------------
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e55fe323/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 8d12bc4..7493ca2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: c
install:
- sudo apt-get update -qq
- - sudo apt-get install -y -qq bash cmake libssl-dev maven ruby python php5 openjdk-7-jdk swig uuid-dev valgrind
+ - sudo apt-get install -y -qq bash cmake libssl-dev maven ruby python php5 openjdk-7-jdk swig uuid-dev valgrind libsasl2-dev sasl2-bin
script:
- bin/jenkins-proton-c-build.sh
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[48/50] qpid-proton git commit: PROTON-781: Added Backoff to the Ruby
reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added Backoff to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0910020a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0910020a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0910020a
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 0910020a043e71491eee609ab74c63c6ede659ba
Parents: 566a8e5
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 16:39:13 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/reactor/backoff.rb | 41 ++++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0910020a/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 6047613..661927e 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -104,6 +104,7 @@ require "reactor/ssl_config"
require "reactor/global_overrides"
require "reactor/urls"
require "reactor/connector"
+require "reactor/backoff"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0910020a/proton-c/bindings/ruby/lib/reactor/backoff.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/backoff.rb b/proton-c/bindings/ruby/lib/reactor/backoff.rb
new file mode 100644
index 0000000..99682e5
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/backoff.rb
@@ -0,0 +1,41 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class Backoff
+
+ def initialize
+ @delay = 0
+ end
+
+ def reset
+ @delay = 0
+ end
+
+ def next
+ current = @delay
+ current = 0.1 if current.zero?
+ @delay = [10, 2 * current].min
+ return current
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[50/50] qpid-proton git commit: PROTON-781: Update CMake to install
new Ruby packages.
Posted by mc...@apache.org.
PROTON-781: Update CMake to install new Ruby packages.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/534c3410
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/534c3410
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/534c3410
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 534c3410cde77867fd6799f4aa590aca172f73bc
Parents: 717377a
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Jun 18 10:02:42 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 10:02:42 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/CMakeLists.txt | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/534c3410/proton-c/bindings/ruby/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/CMakeLists.txt b/proton-c/bindings/ruby/CMakeLists.txt
index c6b07d3..55c232a 100644
--- a/proton-c/bindings/ruby/CMakeLists.txt
+++ b/proton-c/bindings/ruby/CMakeLists.txt
@@ -77,13 +77,18 @@ install(DIRECTORY lib/core
install(DIRECTORY lib/event
DESTINATION ${RUBY_ARCHLIB_DIR}
COMPONENT Ruby)
+install(DIRECTORY lib/handler
+ DESTINATION ${RUBY_ARCHLIB_DIR}
+ COMPONENT Ruby)
install(DIRECTORY lib/messenger
DESTINATION ${RUBY_ARCHLIB_DIR}
COMPONENT Ruby)
+install(DIRECTORY lib/reactor
+ DESTINATION ${RUBY_ARCHLIB_DIR}
+ COMPONENT Ruby)
install(DIRECTORY lib/types
DESTINATION ${RUBY_ARCHLIB_DIR}
COMPONENT Ruby)
install(DIRECTORY lib/util
DESTINATION ${RUBY_ARCHLIB_DIR}
COMPONENT Ruby)
-
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[24/50] qpid-proton git commit: PROTON-781: Added Reactor and Task to
the ClassWrapper
Posted by mc...@apache.org.
PROTON-781: Added Reactor and Task to the ClassWrapper
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ac46b78f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ac46b78f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ac46b78f
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: ac46b78fa0e44df97cb499cff9942c7f00de0a31
Parents: a7f9d4b
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 10:54:54 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/util/class_wrapper.rb | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ac46b78f/proton-c/bindings/ruby/lib/util/class_wrapper.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/class_wrapper.rb b/proton-c/bindings/ruby/lib/util/class_wrapper.rb
index 134f655..dec16e9 100644
--- a/proton-c/bindings/ruby/lib/util/class_wrapper.rb
+++ b/proton-c/bindings/ruby/lib/util/class_wrapper.rb
@@ -36,6 +36,8 @@ module Qpid::Proton::Util
"pn_delivery" => proc {|x| Qpid::Proton::Delivery.wrap(Cproton.pn_cast_pn_delivery(x))},
"pn_transport" => proc {|x| Qpid::Proton::Transport.wrap(Cproton.pn_cast_pn_transport(x))},
"pn_selectable" => proc {|x| Qpid::Proton::Selectable.wrap(Cproton.pn_cast_pn_selectable(x))},
+ "pn_reactor" => proc {|x| Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_cast_pn_reactor(x))},
+ "pn_task" => proc {|x| Qpid::Proton::Reactor::Task.wrap(Cproton.pn_cast_pn_task(x))},
}
def class_wrapper(clazz, c_impl, &block)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[17/50] qpid-proton git commit: PROTON-799: Update CMake INSTALL for
81a5449
Posted by mc...@apache.org.
PROTON-799: Update CMake INSTALL for 81a5449
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/175a15a8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/175a15a8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/175a15a8
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 175a15a8773a3c04ca3e84673ce4e35f612e8639
Parents: 83f424f
Author: Dominic Evans <do...@uk.ibm.com>
Authored: Thu Jun 18 11:04:32 2015 +0100
Committer: Dominic Evans <do...@uk.ibm.com>
Committed: Thu Jun 18 11:04:32 2015 +0100
----------------------------------------------------------------------
proton-c/bindings/ruby/CMakeLists.txt | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/175a15a8/proton-c/bindings/ruby/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/CMakeLists.txt b/proton-c/bindings/ruby/CMakeLists.txt
index e42db32..c6b07d3 100644
--- a/proton-c/bindings/ruby/CMakeLists.txt
+++ b/proton-c/bindings/ruby/CMakeLists.txt
@@ -68,6 +68,22 @@ install(TARGETS cproton-ruby
install(FILES lib/qpid_proton.rb
DESTINATION ${RUBY_ARCHLIB_DIR}
COMPONENT Ruby)
-install(DIRECTORY lib/qpid_proton
+install(DIRECTORY lib/codec
DESTINATION ${RUBY_ARCHLIB_DIR}
COMPONENT Ruby)
+install(DIRECTORY lib/core
+ DESTINATION ${RUBY_ARCHLIB_DIR}
+ COMPONENT Ruby)
+install(DIRECTORY lib/event
+ DESTINATION ${RUBY_ARCHLIB_DIR}
+ COMPONENT Ruby)
+install(DIRECTORY lib/messenger
+ DESTINATION ${RUBY_ARCHLIB_DIR}
+ COMPONENT Ruby)
+install(DIRECTORY lib/types
+ DESTINATION ${RUBY_ARCHLIB_DIR}
+ COMPONENT Ruby)
+install(DIRECTORY lib/util
+ DESTINATION ${RUBY_ARCHLIB_DIR}
+ COMPONENT Ruby)
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[16/50] qpid-proton git commit: NO-JIRA: add ruby-dev and python-dev
to travis
Posted by mc...@apache.org.
NO-JIRA: add ruby-dev and python-dev to travis
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/83f424f5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/83f424f5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/83f424f5
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 83f424f5dc7789cc8dce7e7a96dde63dd415b478
Parents: 3aab9a0
Author: Dominic Evans <do...@uk.ibm.com>
Authored: Wed Jun 17 16:03:43 2015 +0100
Committer: Dominic Evans <do...@uk.ibm.com>
Committed: Thu Jun 18 10:52:04 2015 +0100
----------------------------------------------------------------------
.travis.yml | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/83f424f5/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 7493ca2..6d1a73e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,12 @@
+---
language: c
install:
- - sudo apt-get update -qq
- - sudo apt-get install -y -qq bash cmake libssl-dev maven ruby python php5 openjdk-7-jdk swig uuid-dev valgrind libsasl2-dev sasl2-bin
+- sudo apt-get update -qq
+- sudo apt-get install -y -qq bash cmake libssl-dev maven ruby ruby-dev
+ python python-dev php5 openjdk-7-jdk swig uuid-dev valgrind libsasl2-dev
+ sasl2-bin
+- gem install rspec simplecov
script:
- - bin/jenkins-proton-c-build.sh
+- bin/jenkins-proton-c-build.sh
+os:
+- linux
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[06/50] qpid-proton git commit: PROTON-913: cannot use NULL as first
param for pn_transport_log()
Posted by mc...@apache.org.
PROTON-913: cannot use NULL as first param for pn_transport_log()
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c2c178c9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c2c178c9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c2c178c9
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: c2c178c9ce4bbad7b81e925a3f49f5e80fe60e62
Parents: 75fc98f
Author: Gordon Sim <gs...@redhat.com>
Authored: Fri Jun 12 20:28:05 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Fri Jun 12 20:28:05 2015 +0100
----------------------------------------------------------------------
proton-c/src/ssl/openssl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c2c178c9/proton-c/src/ssl/openssl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/openssl.c b/proton-c/src/ssl/openssl.c
index 52eac01..a5aee8b 100644
--- a/proton-c/src/ssl/openssl.c
+++ b/proton-c/src/ssl/openssl.c
@@ -730,7 +730,7 @@ int pn_ssl_domain_allow_unsecured_client(pn_ssl_domain_t *domain)
{
if (!domain) return -1;
if (domain->mode != PN_SSL_MODE_SERVER) {
- pn_transport_log(NULL, "Cannot permit unsecured clients - not a server.");
+ pn_transport_logf(NULL, "Cannot permit unsecured clients - not a server.");
return -1;
}
domain->allow_unsecured = true;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[23/50] qpid-proton git commit: PROTON-781: Added the WrappedHandler
class to the Ruby reactor APIs.
Posted by mc...@apache.org.
PROTON-781: Added the WrappedHandler class to the Ruby reactor APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/17597761
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/17597761
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/17597761
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 175977616b46471d758c716a7ed16fe67962e274
Parents: e38957a
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon Feb 23 16:18:01 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:19 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/handler/c_adaptor.rb | 47 ++++++++++++
.../ruby/lib/handler/wrapped_handler.rb | 76 ++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 4 ++
proton-c/bindings/ruby/ruby.i | 53 ++++++++++++++
4 files changed, 180 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/17597761/proton-c/bindings/ruby/lib/handler/c_adaptor.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/c_adaptor.rb b/proton-c/bindings/ruby/lib/handler/c_adaptor.rb
new file mode 100644
index 0000000..ef4852e
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/c_adaptor.rb
@@ -0,0 +1,47 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ # @private
+ class CAdaptor
+
+ def initialize(handler, on_error = nil)
+ @handler = handler
+ @on_error = on_error
+ end
+
+ def dispatch(cevent, ctype)
+ event = Qpid::Proton::Event::Event.wrap(cevent, ctype)
+ # TODO add a variable to enable this programmatically
+ # print "EVENT: #{event} going to #{@handler}\n"
+ event.dispatch(@handler)
+ end
+
+ def exception(error)
+ if @on_error.nil?
+ raise error
+ else
+ @on_error.call(error)
+ end
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/17597761/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb b/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb
new file mode 100644
index 0000000..6d55dee
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb
@@ -0,0 +1,76 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ class WrappedHandler
+
+ # @private
+ include Qpid::Proton::Util::Wrapper
+
+ def self.wrap(impl, on_error = nil)
+ return nil if impl.nil?
+
+ result = self.fetch_instance(impl) || WrappedHandler.new(impl)
+ result.on_error = on_error
+ return result
+ end
+
+ include Qpid::Proton::Util::Handler
+
+ def initialize(impl_or_constructor)
+ if impl_or_constructor.is_a?(Method)
+ @impl = impl_or_constructor.call
+ else
+ @impl = impl_or_constructor
+ Cproton.pn_incref(@impl)
+ end
+ @on_error = nil
+ self.class.store_instance(self)
+ end
+
+ def add(handler)
+ return if handler.nil?
+
+ impl = chandler(handler, self.method(:_on_error))
+ Cproton.pn_handler_add(@impl, impl)
+ Cproton.pn_decref(impl)
+ end
+
+ def clear
+ Cproton.pn_handler_clear(@impl)
+ end
+
+ def on_error=(on_error)
+ @on_error = on_error
+ end
+
+ private
+
+ def _on_error(info)
+ if self.has?['on_error']
+ self['on_error'].call(info)
+ else
+ raise info
+ end
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/17597761/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 467d959..2791538 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -82,6 +82,10 @@ require "messenger/tracker"
require "messenger/selectable"
require "messenger/messenger"
+# Handler classes
+require "handler/c_adaptor"
+require "handler/wrapped_handler"
+
module Qpid::Proton
# @private
def self.registry
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/17597761/proton-c/bindings/ruby/ruby.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i
index 678a085..3d4090e 100644
--- a/proton-c/bindings/ruby/ruby.i
+++ b/proton-c/bindings/ruby/ruby.i
@@ -559,4 +559,57 @@ VALUE pni_address_of(void *object) {
int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
%ignore pn_ssl_get_peer_hostname;
+%inline %{
+
+ VALUE pni_ruby_get_proton_module() {
+ VALUE mQpid = rb_define_module("Qpid");
+ return rb_define_module_under(mQpid, "Proton");
+ }
+
+ void pni_ruby_add_to_registry(VALUE key, VALUE value) {
+ VALUE result = rb_funcall(pni_ruby_get_proton_module(), rb_intern("add_to_registry"), 2, key, value);
+ }
+
+ VALUE pni_ruby_get_from_registry(VALUE key) {
+ rb_funcall(pni_ruby_get_proton_module(), rb_intern("get_from_registry"), 1, key);
+ }
+
+ void pni_ruby_delete_from_registry(VALUE stored_key) {
+ rb_funcall(pni_ruby_get_proton_module(), rb_intern("delete_from_registry"), 1, stored_key);
+ }
+
+ typedef struct {
+ VALUE handler_key;
+ } pni_rbhandler_t;
+
+ static pni_rbhandler_t *pni_rbhandler(pn_handler_t *handler) {
+ return (pni_rbhandler_t *) pn_handler_mem(handler);
+ }
+
+ static void pni_rbdispatch(pn_handler_t *handler, pn_event_t *event, pn_event_type_t type) {
+ pni_rbhandler_t *rbh = pni_rbhandler(handler);
+ VALUE rbhandler = pni_ruby_get_from_registry(rbh->handler_key);
+
+ rb_funcall(rbhandler, rb_intern("dispatch"), 2, SWIG_NewPointerObj(event, SWIGTYPE_p_pn_event_t, 0), INT2FIX(type));
+ }
+
+ static void pni_rbhandler_finalize(pn_handler_t *handler) {
+ pni_rbhandler_t *rbh = pni_rbhandler(handler);
+ pni_ruby_delete_from_registry(rbh->handler_key);
+ }
+
+ pn_handler_t *pn_rbhandler(VALUE handler) {
+ pn_handler_t *chandler = pn_handler_new(pni_rbdispatch, sizeof(pni_rbhandler_t), pni_rbhandler_finalize);
+ pni_rbhandler_t *rhy = pni_rbhandler(chandler);
+
+ VALUE ruby_key = rb_class_new_instance(0, NULL, rb_cObject);
+ pni_ruby_add_to_registry(ruby_key, handler);
+
+ rhy->handler_key = ruby_key;
+
+ return chandler;
+ }
+
+%}
+
%include "proton/cproton.i"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[39/50] qpid-proton git commit: PROTON-781: Added SSLConfig to the
Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added SSLConfig to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e21dec95
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e21dec95
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e21dec95
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: e21dec955a4637c33de618a23b58d2b8428b7928
Parents: 07ddaaf
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Feb 26 11:28:04 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
.../bindings/ruby/lib/reactor/ssl_config.rb | 41 ++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e21dec95/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index f8703e7..d8783bc 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -96,6 +96,7 @@ require "handler/messaging_handler"
require "reactor/task"
require "reactor/acceptor"
require "reactor/reactor"
+require "reactor/ssl_config"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e21dec95/proton-c/bindings/ruby/lib/reactor/ssl_config.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/ssl_config.rb b/proton-c/bindings/ruby/lib/reactor/ssl_config.rb
new file mode 100644
index 0000000..56fec71
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/ssl_config.rb
@@ -0,0 +1,41 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class SSLConfig
+
+ def initialize
+ @client = Qpid::Proton::SSLDomain.new(Qpid::Proton::SSLDomain::MODE_CLIENT)
+ @server = Qpid::Proton::SSLDomain.new(Qpid::Proton::SSLDomain::MODE_SERVER)
+ end
+
+ def set_credentials(cert_file, key_file, password)
+ @client.set_credentials(cert_file, key_file, password)
+ @server.set_credentials(cert_file, key_file, password)
+ end
+
+ def set_trusted_ca_db(certificate_db)
+ @client.set_trusted_ca_db(certificate_db)
+ @server.set_trusted_ca_db(certificate_db)
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[09/50] qpid-proton git commit: PROTON-908: Remove install-runtime
dependency on swig
Posted by mc...@apache.org.
PROTON-908: Remove install-runtime dependency on swig
The patch allows python-qpid-proton for generating the `cproton_wrap.c`
file when creating the distribution package. Since this file is already
cross-platform, it should be safe to ship it as part of the
python-qpid-proton package.
This allows us for building the bindings even when swig is not
available. The setup.py process will try to generate a new
cproton_wrap.c everytime but it'll fallback to the one distributed with
the package if swig is not available.
Note that this will be done just in the platforms where bundling
proton-c is supported. The reason being that, in the other platforms, w
can't verify whether the installed qpid-proton version is the same that
was used to generated these files
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/56af1189
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/56af1189
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/56af1189
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 56af1189cf2e6a769b0452a102a795a6f906b470
Parents: 821b4e1
Author: Flavio Percoco <fl...@gmail.com>
Authored: Thu Jun 11 10:24:36 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Tue Jun 16 13:06:46 2015 -0400
----------------------------------------------------------------------
proton-c/CMakeLists.txt | 2 +-
proton-c/bindings/python/setup.py | 58 +++++++++++++++++++++++++++++++---
2 files changed, 54 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56af1189/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 5b05e38..5985e2d 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -520,7 +520,7 @@ if (BUILD_PYTHON)
to_native_path ("${py_pythonpath}" py_pythonpath)
add_test (NAME python-tox-test
COMMAND ${env_py}
- "PATH=${py_path}" ${VALGRIND_ENV}
+ "PATH=${py_path}" "QPID_PROTON_SRC=${CMAKE_CURRENT_SOURCE_DIR}/../" ${VALGRIND_ENV}
tox
WORKING_DIRECTORY ${py_src})
set_tests_properties(python-tox-test PROPERTIES PASS_REGULAR_EXPRESSION "Totals: .* 0 failed")
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56af1189/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index 84b5a66..0a77872 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -78,12 +78,32 @@ from distutils.ccompiler import new_compiler, get_default_compiler
from distutils.core import setup, Extension
from distutils.command.build import build
from distutils.command.build_ext import build_ext
+from distutils.command.sdist import sdist
+from distutils import errors
from setuputils import bundle
from setuputils import log
from setuputils import misc
+class CheckSDist(sdist):
+
+ def run(self):
+ self.distribution.run_command('configure')
+
+ # Append the source that was removed during
+ # the configuration step.
+ _cproton = self.distribution.ext_modules[-1]
+ _cproton.sources.append('cproton.i')
+
+ try:
+ sdist.run(self)
+ finally:
+ for src in ['cproton.py', 'cproton_wrap.c']:
+ if os.path.exists(src):
+ os.remove(src)
+
+
class Configure(build_ext):
description = "Discover Qpid Proton version"
@@ -97,6 +117,21 @@ class Configure(build_ext):
else:
return compiler.compiler_type
+ def prepare_swig_wrap(self):
+ ext = self.distribution.ext_modules[-1]
+
+ try:
+ # This will actually call swig to generate the files
+ # and list the sources.
+ self.swig_sources(ext.sources, ext)
+ except (errors.DistutilsExecError, errors.DistutilsPlatformError) as e:
+ if not (os.path.exists('cproton_wrap.c') or
+ os.path.exists('cproton.py')):
+ raise e
+
+ ext.sources = ext.sources[1:]
+ ext.swig_opts = []
+
def bundle_libqpid_proton_extension(self):
base = self.get_finalized_command('build').build_base
build_include = os.path.join(base, 'include')
@@ -262,6 +297,7 @@ class Configure(build_ext):
_cproton = self.distribution.ext_modules[-1]
_cproton.library_dirs.append(self.build_lib)
_cproton.include_dirs.append(proton_include)
+ _cproton.include_dirs.append(build_include)
_cproton.include_dirs.append(os.path.join(proton_src, 'bindings', 'python'))
_cproton.swig_opts.append('-I%s' % build_include)
@@ -283,11 +319,20 @@ class Configure(build_ext):
@property
def bundle_proton(self):
"""Bundled proton if the conditions below are met."""
- return sys.platform == 'linux2' and not self.check_qpid_proton_version()
+ return not self.check_qpid_proton_version()
def run(self):
- if self.bundle_proton:
- self.bundle_libqpid_proton_extension()
+ if sys.platform == 'linux2':
+ if self.bundle_proton:
+ self.bundle_libqpid_proton_extension()
+
+ # Do this just on linux since it's the only
+ # platform we support building the bundle for
+ # and especially, it's the only platform we check
+ # the, hopefully installed, qpid-proton version.
+ # This avoids re-using the distributed wrappers with
+ # uncompatible versions.
+ self.prepare_swig_wrap()
class CustomBuildOrder(build):
@@ -316,7 +361,8 @@ class CheckingBuildExt(build_ext):
# Override `build_ext` and add `configure`
cmdclass = {'configure': Configure,
'build': CustomBuildOrder,
- 'build_ext': CheckingBuildExt}
+ 'build_ext': CheckingBuildExt,
+ 'sdist': CheckSDist}
setup(name='python-qpid-proton',
@@ -332,6 +378,8 @@ setup(name='python-qpid-proton',
"Intended Audience :: Developers",
"Programming Language :: Python"],
cmdclass = cmdclass,
- ext_modules=[Extension('_cproton', ['cproton.i'],
+ ext_modules=[Extension('_cproton',
+ sources=['cproton.i', 'cproton_wrap.c'],
swig_opts=['-threads'],
+ extra_compile_args=['-pthread'],
libraries=['qpid-proton'])])
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[32/50] qpid-proton git commit: PROTON-781: Added MessagingHandler to
the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added MessagingHandler to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/7c93d880
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7c93d880
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7c93d880
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 7c93d880076c5740afe17bb8289242dbac752dc7
Parents: 1378980
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Feb 25 13:32:09 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
.../ruby/lib/handler/messaging_handler.rb | 218 +++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 219 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c93d880/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/messaging_handler.rb b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
new file mode 100644
index 0000000..b4a0bcf
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
@@ -0,0 +1,218 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ # A general purpose handler that simplifies processing events.
+ #
+ # @example
+ #
+ class MessagingHandler < Qpid::Proton::BaseHandler
+
+ attr_reader :handlers
+
+ # Creates a new instance.
+ #
+ # @param [Fixnum] prefetch
+ # @param [Boolean] auto_accept
+ # @param [Boolean] auto_settle
+ # @param [Boolean] peer_close_is_error
+ #
+ def initialize(prefetch = 10, auto_accept = true, auto_settle = true, peer_close_is_error = false)
+ @handlers = Array.new
+ @handlers << CFlowController.new(prefetch) unless prefetch.zero?
+ @handlers << EndpointStateHandler.new(peer_close_is_error, self)
+ @handlers << IncomingMessageHandler.new(auto_accept, self)
+ @handlers << OutgoingMessageHandler.new(auto_settle,self)
+ end
+
+ # Called when the peer closes the connection with an error condition.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_connection_error(event)
+ EndpointStateHandler.print_error(event.connection, "connection")
+ end
+
+ # Called when the peer closes the session with an error condition.
+ #
+ # @param event [Qpid:Proton::Event::Event] The event.
+ #
+ def on_session_error(event)
+ EndpointStateHandler.print_error(event.session, "session")
+ event.connection.close
+ end
+
+ # Called when the peer closes the link with an error condition.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_link_error(event)
+ EndpointStateHandler.print_error(event.link, "link")
+ event.connection.close
+ end
+
+ # Called when the event loop starts.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_reactor_init(event)
+ self.on_start(event)
+ end
+
+ # Called when the event loop starts.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_start(event)
+ end
+
+ # Called when the connection is closed.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_connection_closed(event)
+ end
+
+ # Called when the session is closed.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_session_closed(event)
+ end
+
+ # Called when the link is closed.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_link_closed(event)
+ end
+
+ # Called when the peer initiates the closing of the connection.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_connection_closing(event)
+ end
+
+ # Called when the peer initiates the closing of the session.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_session_closing(event)
+ end
+
+ # Called when the peer initiates the closing of the link.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_link_closing(event)
+ end
+
+ # Called when the socket is disconnected.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_disconnected(event)
+ end
+
+ # Called when the sender link has credit and messages can therefore
+ # be transferred.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_sendable(event)
+ end
+
+ # Called when the remote peer accepts an outgoing message.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_accepted(event)
+ end
+
+ # Called when the remote peer rejects an outgoing message.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_rejected(event)
+ end
+
+ # Called when the remote peer releases an outgoing message.
+ #
+ # Note that this may be in response to either the RELEASE or
+ # MODIFIED state as defined by the AMPQ specification.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_released(event)
+ end
+
+ # Called when the remote peer has settled hte outgoing message.
+ #
+ # This is the point at which it should never be retransmitted.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_settled(event)
+ end
+
+ # Called when a message is received.
+ #
+ # The message itself can be obtained as a property on the event. For
+ # the purpose of referring to this message in further actions, such as
+ # explicitly accepting it) the delivery should be used. This is also
+ # obtainable vi a property on the event.
+ #
+ # This method needs to be overridden.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_message(event)
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c93d880/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 5c2e1bc..a60a028 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -90,6 +90,7 @@ require "handler/endpoint_state_handler"
require "handler/incoming_message_handler"
require "handler/outgoing_message_handler"
require "handler/c_flow_controller"
+require "handler/messaging_handler"
module Qpid::Proton
# @private
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[38/50] qpid-proton git commit: PROTON-781: Added GlobalOverrides to
the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added GlobalOverrides to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1c20ad63
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1c20ad63
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1c20ad63
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 1c20ad63d89030422f467f65e40322dd87926429
Parents: e21dec9
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Feb 26 11:28:35 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
.../ruby/lib/reactor/global_overrides.rb | 44 ++++++++++++++++++++
2 files changed, 45 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1c20ad63/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index d8783bc..5b0d23f 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -97,6 +97,7 @@ require "reactor/task"
require "reactor/acceptor"
require "reactor/reactor"
require "reactor/ssl_config"
+require "reactor/global_overrides"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1c20ad63/proton-c/bindings/ruby/lib/reactor/global_overrides.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/global_overrides.rb b/proton-c/bindings/ruby/lib/reactor/global_overrides.rb
new file mode 100644
index 0000000..11d05a5
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/global_overrides.rb
@@ -0,0 +1,44 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class GlobalOverrides
+
+ def initialize(base)
+ @base = base
+ end
+
+ def on_unhandled(name, event)
+ event.dispatch(@base) unless self.override?(event)
+ end
+
+ def override?(event)
+ conn = event.connection
+ if !conn.nil? && conn.overrides?
+ overrides = conn.overrides
+ result = event.dispatch(overrides)
+ return result
+ end
+ false
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[45/50] qpid-proton git commit: PROTON-781: Added URLs to the Ruby
reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added URLs to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/56f461fb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/56f461fb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/56f461fb
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 56f461fb77e8f18548448cfbf07dcd9c4eabccae
Parents: afd25a6
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 16:38:04 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/reactor/urls.rb | 40 +++++++++++++++++++++++++
2 files changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56f461fb/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 11a555f..4f017e1 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -102,6 +102,7 @@ require "reactor/acceptor"
require "reactor/reactor"
require "reactor/ssl_config"
require "reactor/global_overrides"
+require "reactor/urls"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56f461fb/proton-c/bindings/ruby/lib/reactor/urls.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/urls.rb b/proton-c/bindings/ruby/lib/reactor/urls.rb
new file mode 100644
index 0000000..8cdb16c
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/urls.rb
@@ -0,0 +1,40 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class URLs
+
+ def initialize(values)
+ @values = [values].flatten
+ @iter = @values.each
+ end
+
+ def next
+ begin
+ return @iter.next
+ rescue StopIteration
+ @iter = @values.each
+ return @iter.next
+ end
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[44/50] qpid-proton git commit: PROTON-781: Added Connector to the
Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added Connector to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/566a8e57
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/566a8e57
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/566a8e57
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 566a8e577727aa08d3257b802f91bd3a931bc590
Parents: 56f461f
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 16:38:47 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/reactor/connector.rb | 98 ++++++++++++++++++++
2 files changed, 99 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/566a8e57/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 4f017e1..6047613 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -103,6 +103,7 @@ require "reactor/reactor"
require "reactor/ssl_config"
require "reactor/global_overrides"
require "reactor/urls"
+require "reactor/connector"
module Qpid::Proton
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/566a8e57/proton-c/bindings/ruby/lib/reactor/connector.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/connector.rb b/proton-c/bindings/ruby/lib/reactor/connector.rb
new file mode 100644
index 0000000..a6523db
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/connector.rb
@@ -0,0 +1,98 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Reactor
+
+ class Connector < Qpid::Proton::BaseHandler
+
+ attr_accessor :address
+ attr_accessor :reconnect
+ attr_accessor :ssl_domain
+
+ def initialize(connection)
+ @connection = connection
+ @address = nil
+ @heartbeat = nil
+ @reconnect = nil
+ @ssl_domain = nil
+ end
+
+ def on_connection_local_open(event)
+ self.connect(event.connection)
+ end
+
+ def on_connection_remote_open(event)
+ if !@reconnect.nil?
+ @reconnect.reset
+ @transport = nil
+ end
+ end
+
+ def on_transport_tail_closed(event)
+ self.on_transport_closed(event)
+ end
+
+ def on_transport_closed(event)
+ if !@connection.nil? && !(@connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
+ if !@reconnect.nil?
+ event.transport.unbind
+ delay = @reconnect.next
+ if delay == 0
+ self.connect(@connection)
+ else
+ event.reactor.schedule(delay, self)
+ end
+ else
+ @connection = nil
+ end
+ end
+ end
+
+ def on_timer_task(event)
+ self.connect(@connection)
+ end
+
+ def on_connection_remote_close(event)
+ @connection = nil
+ end
+
+ def connect(connection)
+ url = @address.next
+ connection.hostname = "#{url.host}:#{url.port}"
+
+ transport = Qpid::Proton::Transport.new
+ transport.bind(connection)
+ if !@heartbeat.nil?
+ transport.idle_timeout = @heartbeat
+ elsif (url.scheme == "amqps") && !@ssl_domain.nil?
+ @ssl = Qpid::Proton::SSL.new(transport, @ssl_domain)
+ @ss.peer_hostname = url.host
+ elsif !url.username.nil?
+ sasl = transport.sasl
+ if url.username == "anonymous"
+ sasl.mechanisms("ANONYMOUS")
+ else
+ sasl.plain(url.username, url.password)
+ end
+ end
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[46/50] qpid-proton git commit: PROTON-781: Ruby registry and memory
management testing
Posted by mc...@apache.org.
PROTON-781: Ruby registry and memory management testing
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3211bd5c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3211bd5c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3211bd5c
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 3211bd5ccd40351890fcd7bef91341e5129f8658
Parents: c84aace
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Fri May 8 10:54:13 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:21 2015 -0400
----------------------------------------------------------------------
examples/ruby/registry_test.rb | 76 +++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3211bd5c/examples/ruby/registry_test.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/registry_test.rb b/examples/ruby/registry_test.rb
new file mode 100644
index 0000000..b4b1f6c
--- /dev/null
+++ b/examples/ruby/registry_test.rb
@@ -0,0 +1,76 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'weakref'
+
+def show_registry(registry)
+ registry.each_pair do |key, value|
+ registry.delete(key) if value.weakref_alive?
+ end
+ puts "The contents of the registry: size=#{registry.size}"
+end
+
+def show_object_count(clazz)
+ puts "There are #{ObjectSpace.each_object(clazz).count} instances of #{clazz}."
+end
+
+impl = Cproton.pn_transport
+implclazz = impl.class
+transport = Qpid::Proton::Transport.wrap(impl)
+
+puts "Initial setup:"
+show_object_count(Qpid::Proton::Transport)
+show_object_count(implclazz)
+
+transport = nil
+
+show_registry(Qpid::Proton.registry)
+
+ObjectSpace.garbage_collect
+
+puts "After garbage collection:"
+show_object_count(Qpid::Proton::Transport)
+show_object_count(implclazz)
+
+MAXCOUNT=100000
+(1..MAXCOUNT).each do |which|
+ nimpl = Cproton.pn_transport
+ Cproton.pn_incref(nimpl)
+ transport = Qpid::Proton::Transport.wrap(nimpl)
+ transport = Qpid::Proton::Transport.wrap(nimpl)
+end
+
+transport = nil
+
+puts "After creating #{MAXCOUNT} instances"
+show_object_count(Qpid::Proton::Transport)
+show_object_count(implclazz)
+show_registry(Qpid::Proton.registry)
+
+ObjectSpace.garbage_collect
+
+transport = Qpid::Proton::Transport.wrap(impl)
+
+puts "After garbage collection:"
+puts "impl=#{impl}"
+puts "transport=#{transport}"
+show_object_count(Qpid::Proton::Transport)
+show_object_count(implclazz)
+show_registry(Qpid::Proton.registry)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[05/50] qpid-proton git commit: PROTON-904: fix javascript build
after removal of liuuid as dependency of proton-c
Posted by mc...@apache.org.
PROTON-904: fix javascript build after removal of liuuid as dependency of proton-c
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/75fc98fd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/75fc98fd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/75fc98fd
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 75fc98fd70bf563dfebdf6b47e55ee83d2c0fc7e
Parents: f6e1948
Author: Gordon Sim <gs...@redhat.com>
Authored: Fri Jun 12 20:03:59 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Fri Jun 12 20:03:59 2015 +0100
----------------------------------------------------------------------
proton-c/bindings/javascript/CMakeLists.txt | 9 +++++++--
proton-c/bindings/javascript/binding.c | 2 ++
2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/75fc98fd/proton-c/bindings/javascript/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/CMakeLists.txt b/proton-c/bindings/javascript/CMakeLists.txt
index 699cf07..5a87baf 100644
--- a/proton-c/bindings/javascript/CMakeLists.txt
+++ b/proton-c/bindings/javascript/CMakeLists.txt
@@ -77,6 +77,10 @@ set(pn_ssl_impl ${PN_PATH}/src/ssl/ssl_stub.c)
set(pn_io_impl ${PN_PATH}/src/posix/io.c)
set(pn_selector_impl ${PN_PATH}/src/posix/selector.c)
+CHECK_LIBRARY_EXISTS (uuid uuid_generate "" UUID_GENERATE_IN_UUID)
+if (UUID_GENERATE_IN_UUID)
+ set (UUID_LIB uuid)
+endif (UUID_GENERATE_IN_UUID)
# Generate encodings.h and protocol.h
# It may be possible to use the ones generated for the main proton-c build but
@@ -183,6 +187,7 @@ set_target_properties(
SOVERSION "${PN_LIB_SOMAJOR}"
LINK_FLAGS "${CATCH_UNDEFINED}"
)
+target_link_libraries(qpid-proton-bitcode)
# Compile the send-async.c and recv-async.c examples into JavaScript
@@ -204,7 +209,7 @@ set_target_properties(
# Build the main JavaScript library called proton-messenger.js
add_executable(proton-messenger.js binding.c)
-target_link_libraries(proton-messenger.js qpid-proton-bitcode)
+target_link_libraries(proton-messenger.js qpid-proton-bitcode ${UUID_LIB})
set_target_properties(
proton-messenger.js
@@ -217,7 +222,7 @@ set_target_properties(
# more fiddly with node.js packages. This behaviour might be reinstated if the
# packaging mechanism improves.
- LINK_FLAGS "-s \"EXPORT_NAME='proton'\" -s \"WEBSOCKET_SUBPROTOCOL='AMQPWSB10'\" ${EMSCRIPTEN_LINK_OPTIMISATIONS} --memory-init-file 0 --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/binding-open.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/module.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/error.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/messenger.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/subscription.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/message.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-uuid.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-symbol.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-described.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-array.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-typed-number.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-long.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-binary.js --post-js ${CMAKE_CURRENT_SOURCE_DIR}/binding-close.js -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=\"[]\" -s EXPORTED_FUNCTIONS=\"['_pn_get_version_major', '_
pn_get_version_minor', '_pn_bytes', '_pn_error_text', '_pn_code', '_pn_messenger', '_pn_messenger_name', '_pn_messenger_set_blocking', '_pn_messenger_free', '_pn_messenger_errno', '_pn_messenger_error', '_pn_messenger_get_outgoing_window', '_pn_messenger_set_outgoing_window', '_pn_messenger_get_incoming_window', '_pn_messenger_set_incoming_window', '_pn_messenger_start', '_pn_messenger_stop', '_pn_messenger_stopped', '_pn_messenger_subscribe', '_pn_messenger_put', '_pn_messenger_status', '_pn_messenger_buffered', '_pn_messenger_settle', '_pn_messenger_outgoing_tracker', '_pn_messenger_recv', '_pn_messenger_receiving', '_pn_messenger_get', '_pn_messenger_incoming_tracker', '_pn_messenger_incoming_subscription', '_pn_messenger_accept', '_pn_messenger_reject', '_pn_messenger_outgoing', '_pn_messenger_incoming', '_pn_messenger_route', '_pn_messenger_rewrite', '_pn_messenger_set_passive', '_pn_messenger_selectable', '_pn_subscription_get_context', '_pn_subscription_set_context', '_pn_su
bscription_address', '_pn_message', '_pn_message_id', '_pn_message_correlation_id', '_pn_message_free', '_pn_message_errno', '_pn_message_error', '_pn_message_clear', '_pn_message_is_inferred', '_pn_message_set_inferred', '_pn_message_is_durable', '_pn_message_set_durable', '_pn_message_get_priority', '_pn_message_set_priority', '_pn_message_get_ttl', '_pn_message_set_ttl', '_pn_message_is_first_acquirer', '_pn_message_set_first_acquirer', '_pn_message_get_delivery_count', '_pn_message_set_delivery_count', '_pn_message_get_user_id', '_pn_message_set_user_id', '_pn_message_get_address', '_pn_message_set_address', '_pn_message_get_subject', '_pn_message_set_subject', '_pn_message_get_reply_to', '_pn_message_set_reply_to', '_pn_message_get_content_type', '_pn_message_set_content_type', '_pn_message_get_content_encoding', '_pn_message_set_content_encoding', '_pn_message_get_expiry_time', '_pn_message_set_expiry_time', '_pn_message_get_creation_time', '_pn_message_set_creation_time', '_p
n_message_get_group_id', '_pn_message_set_group_id', '_pn_message_get_group_sequence', '_pn_message_set_group_sequence', '_pn_message_get_reply_to_group_id', '_pn_message_set_reply_to_group_id', '_pn_message_encode', '_pn_message_decode', '_pn_message_instructions', '_pn_message_annotations', '_pn_message_properties', '_pn_message_body', '_pn_data', '_pn_data_free', '_pn_data_error', '_pn_data_errno', '_pn_data_clear', '_pn_data_rewind', '_pn_data_next', '_pn_data_prev', '_pn_data_enter', '_pn_data_exit', '_pn_data_lookup', '_pn_data_narrow', '_pn_data_widen', '_pn_data_type', '_pn_data_encode', '_pn_data_decode', '_pn_data_put_list', '_pn_data_put_map', '_pn_data_put_array', '_pn_data_put_described', '_pn_data_put_null', '_pn_data_put_bool', '_pn_data_put_ubyte', '_pn_data_put_byte', '_pn_data_put_ushort', '_pn_data_put_short', '_pn_data_put_uint', '_pn_data_put_int', '_pn_data_put_char', '_pn_data_put_ulong', '_pn_data_put_long', '_pn_data_put_timestamp', '_pn_data_put_float', '_p
n_data_put_double', '_pn_data_put_decimal32', '_pn_data_put_decimal64', '_pn_data_put_decimal128', '_pn_data_put_uuid', '_pn_data_put_binary', '_pn_data_put_string', '_pn_data_put_symbol', '_pn_data_get_list', '_pn_data_get_map', '_pn_data_get_array', '_pn_data_is_array_described', '_pn_data_get_array_type', '_pn_data_is_described', '_pn_data_is_null', '_pn_data_get_bool', '_pn_data_get_ubyte', '_pn_data_get_byte', '_pn_data_get_ushort', '_pn_data_get_short', '_pn_data_get_uint', '_pn_data_get_int', '_pn_data_get_char', '_pn_data_get_ulong', '_pn_data_get_long', '_pn_data_get_timestamp', '_pn_data_get_float', '_pn_data_get_double', '_pn_data_get_decimal32', '_pn_data_get_decimal64', '_pn_data_get_decimal128', '_pn_data_get_uuid', '_pn_data_get_binary', '_pn_data_get_string', '_pn_data_get_symbol', '_pn_data_copy', '_pn_data_format', '_pn_data_dump', '_pn_selectable_readable', '_pn_selectable_is_reading', '_pn_selectable_writable', '_pn_selectable_is_writing', '_pn_selectable_is_term
inal', '_pn_selectable_get_fd', '_pn_selectable_free']\""
+ LINK_FLAGS "-s \"EXPORT_NAME='proton'\" -s \"WEBSOCKET_SUBPROTOCOL='AMQPWSB10'\" ${EMSCRIPTEN_LINK_OPTIMISATIONS} --memory-init-file 0 --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/binding-open.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/module.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/error.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/messenger.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/subscription.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/message.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-uuid.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-symbol.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-described.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-array.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-typed-number.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-long.js --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/data-binary.js --post-js ${CMAKE_CURRENT_SOURCE_DIR}/binding-close.js -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=\"[]\" -s EXPORTED_FUNCTIONS=\"['_pn_get_version_major', '_
pn_get_version_minor', '_pn_uuid_generate', '_pn_bytes', '_pn_error_text', '_pn_code', '_pn_messenger', '_pn_messenger_name', '_pn_messenger_set_blocking', '_pn_messenger_free', '_pn_messenger_errno', '_pn_messenger_error', '_pn_messenger_get_outgoing_window', '_pn_messenger_set_outgoing_window', '_pn_messenger_get_incoming_window', '_pn_messenger_set_incoming_window', '_pn_messenger_start', '_pn_messenger_stop', '_pn_messenger_stopped', '_pn_messenger_subscribe', '_pn_messenger_put', '_pn_messenger_status', '_pn_messenger_buffered', '_pn_messenger_settle', '_pn_messenger_outgoing_tracker', '_pn_messenger_recv', '_pn_messenger_receiving', '_pn_messenger_get', '_pn_messenger_incoming_tracker', '_pn_messenger_incoming_subscription', '_pn_messenger_accept', '_pn_messenger_reject', '_pn_messenger_outgoing', '_pn_messenger_incoming', '_pn_messenger_route', '_pn_messenger_rewrite', '_pn_messenger_set_passive', '_pn_messenger_selectable', '_pn_subscription_get_context', '_pn_subscription_
set_context', '_pn_subscription_address', '_pn_message', '_pn_message_id', '_pn_message_correlation_id', '_pn_message_free', '_pn_message_errno', '_pn_message_error', '_pn_message_clear', '_pn_message_is_inferred', '_pn_message_set_inferred', '_pn_message_is_durable', '_pn_message_set_durable', '_pn_message_get_priority', '_pn_message_set_priority', '_pn_message_get_ttl', '_pn_message_set_ttl', '_pn_message_is_first_acquirer', '_pn_message_set_first_acquirer', '_pn_message_get_delivery_count', '_pn_message_set_delivery_count', '_pn_message_get_user_id', '_pn_message_set_user_id', '_pn_message_get_address', '_pn_message_set_address', '_pn_message_get_subject', '_pn_message_set_subject', '_pn_message_get_reply_to', '_pn_message_set_reply_to', '_pn_message_get_content_type', '_pn_message_set_content_type', '_pn_message_get_content_encoding', '_pn_message_set_content_encoding', '_pn_message_get_expiry_time', '_pn_message_set_expiry_time', '_pn_message_get_creation_time', '_pn_message_se
t_creation_time', '_pn_message_get_group_id', '_pn_message_set_group_id', '_pn_message_get_group_sequence', '_pn_message_set_group_sequence', '_pn_message_get_reply_to_group_id', '_pn_message_set_reply_to_group_id', '_pn_message_encode', '_pn_message_decode', '_pn_message_instructions', '_pn_message_annotations', '_pn_message_properties', '_pn_message_body', '_pn_data', '_pn_data_free', '_pn_data_error', '_pn_data_errno', '_pn_data_clear', '_pn_data_rewind', '_pn_data_next', '_pn_data_prev', '_pn_data_enter', '_pn_data_exit', '_pn_data_lookup', '_pn_data_narrow', '_pn_data_widen', '_pn_data_type', '_pn_data_encode', '_pn_data_decode', '_pn_data_put_list', '_pn_data_put_map', '_pn_data_put_array', '_pn_data_put_described', '_pn_data_put_null', '_pn_data_put_bool', '_pn_data_put_ubyte', '_pn_data_put_byte', '_pn_data_put_ushort', '_pn_data_put_short', '_pn_data_put_uint', '_pn_data_put_int', '_pn_data_put_char', '_pn_data_put_ulong', '_pn_data_put_long', '_pn_data_put_timestamp', '_pn
_data_put_float', '_pn_data_put_double', '_pn_data_put_decimal32', '_pn_data_put_decimal64', '_pn_data_put_decimal128', '_pn_data_put_uuid', '_pn_data_put_binary', '_pn_data_put_string', '_pn_data_put_symbol', '_pn_data_get_list', '_pn_data_get_map', '_pn_data_get_array', '_pn_data_is_array_described', '_pn_data_get_array_type', '_pn_data_is_described', '_pn_data_is_null', '_pn_data_get_bool', '_pn_data_get_ubyte', '_pn_data_get_byte', '_pn_data_get_ushort', '_pn_data_get_short', '_pn_data_get_uint', '_pn_data_get_int', '_pn_data_get_char', '_pn_data_get_ulong', '_pn_data_get_long', '_pn_data_get_timestamp', '_pn_data_get_float', '_pn_data_get_double', '_pn_data_get_decimal32', '_pn_data_get_decimal64', '_pn_data_get_decimal128', '_pn_data_get_uuid', '_pn_data_get_binary', '_pn_data_get_string', '_pn_data_get_symbol', '_pn_data_copy', '_pn_data_format', '_pn_data_dump', '_pn_selectable_readable', '_pn_selectable_is_reading', '_pn_selectable_writable', '_pn_selectable_is_writing', '_
pn_selectable_is_terminal', '_pn_selectable_get_fd', '_pn_selectable_free']\""
)
# This command packages up the compiled proton-messenger.js into a node.js package
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/75fc98fd/proton-c/bindings/javascript/binding.c
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/binding.c b/proton-c/bindings/javascript/binding.c
index ecc65dc..8da83f6 100644
--- a/proton-c/bindings/javascript/binding.c
+++ b/proton-c/bindings/javascript/binding.c
@@ -25,10 +25,12 @@
* this is it. This file also provides a way to pass any global variable or
* #defined values to the JavaScript binding by providing wrapper functions.
*/
+#include <uuid/uuid.h>
#include <stdio.h>
#include <proton/version.h>
// To access #define values in JavaScript we need to wrap them in a function.
int pn_get_version_major() {return PN_VERSION_MAJOR;}
int pn_get_version_minor() {return PN_VERSION_MINOR;}
+void pn_uuid_generate(uuid_t out) { uuid_generate(out); }
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[29/50] qpid-proton git commit: PROTON-781: Added
IncomingMessageHandler to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added IncomingMessageHandler to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e165313d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e165313d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e165313d
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: e165313d7cf85a6d5fdaf5cd3072a0f56c337df5
Parents: afdef67
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Feb 26 09:23:00 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/exceptions.rb | 10 +++
.../lib/handler/incoming_message_handler.rb | 74 ++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
3 files changed, 85 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e165313d/proton-c/bindings/ruby/lib/core/exceptions.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/exceptions.rb b/proton-c/bindings/ruby/lib/core/exceptions.rb
index 94d2957..75d6552 100644
--- a/proton-c/bindings/ruby/lib/core/exceptions.rb
+++ b/proton-c/bindings/ruby/lib/core/exceptions.rb
@@ -111,6 +111,16 @@ module Qpid
class SSLUnavailableError < SSLError
end
+ # Raised when a message is rejected.
+ #
+ class Reject < ProtonError
+ end
+
+ # Raised when a message is released.
+ #
+ class Release < ProtonError
+ end
+
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e165313d/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb b/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb
new file mode 100644
index 0000000..ced84a2
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb
@@ -0,0 +1,74 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ # A utility for simpler and more intuitive handling of delivery events
+ # related to incoming messages.
+ #
+ class IncomingMessageHandler < Qpid::Proton::BaseHandler
+
+ include Acking
+
+ def initialize(auto_accept = true, delegate = nil)
+ @delegate = delegate
+ @auto_accept = auto_accept
+ end
+
+ def on_delivery(event)
+ delivery = event.delivery
+ return unless delivery.link.receiver?
+ if delivery.readable? && !delivery.partial?
+ event.message = Qpid::Proton::Util::Engine.receive_message(delivery)
+ if event.link.local_closed?
+ if @auto_accept
+ delivery.update(Qpid::Proton::Disposition::RELEASED)
+ delivery.settle
+ end
+ else
+ begin
+ self.on_message(event)
+ if @auto_accept
+ delivery.update(Qpid::Proton::Disposition::ACCEPTED)
+ delivery.settle
+ end
+ rescue Qpid::Proton::Reject
+ delivery.update(Qpid::Proton::Disposition::REJECTED)
+ delivery.settle
+ rescue Qpid::Proton::Release
+ delivery.update(Qpid::Proton::Disposition::MODIFIED)
+ delivery.settle
+ end
+ end
+ elsif delivery.updated? && delivery.settled?
+ self.on_settled(event)
+ end
+ end
+
+ def on_message(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_message, event) if !@delegate.nil?
+ end
+
+ def on_settled(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil?
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e165313d/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index ef7f300..1fbf710 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -87,6 +87,7 @@ require "handler/c_adaptor"
require "handler/wrapped_handler"
require "handler/acking"
require "handler/endpoint_state_handler"
+require "handler/incoming_message_handler"
require "handler/c_flow_controller"
module Qpid::Proton
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[26/50] qpid-proton git commit: PROTON-781: Added the Reactor mixin
to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added the Reactor mixin to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a7f9d4b2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a7f9d4b2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a7f9d4b2
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: a7f9d4b221749d35e67f425339994d6b844cac17
Parents: 9dcf369
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 16:37:12 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/util/reactor.rb | 32 +++++++++++++++++++++++++
2 files changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a7f9d4b2/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 03f5632..33fe9b6 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -42,6 +42,7 @@ require "util/engine"
require "util/uuid"
require "util/timeout"
require "util/handler"
+require "util/reactor"
# Types
require "types/strings"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a7f9d4b2/proton-c/bindings/ruby/lib/util/reactor.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/reactor.rb b/proton-c/bindings/ruby/lib/util/reactor.rb
new file mode 100644
index 0000000..0bcb557
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/reactor.rb
@@ -0,0 +1,32 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Util
+
+ module Reactor
+
+ def create_session(connection, handler = nil)
+ session = connection.session
+ session.open
+ return session
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[27/50] qpid-proton git commit: PROTON-781: Added the CFlowController
class to the Ruby reactive APIs.
Posted by mc...@apache.org.
PROTON-781: Added the CFlowController class to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e5299b29
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e5299b29
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e5299b29
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: e5299b29844eb3187346d158885abb12fc858fae
Parents: 132e2a3
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Feb 25 13:29:22 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
.../ruby/lib/handler/c_flow_controller.rb | 33 ++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 34 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e5299b29/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb b/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb
new file mode 100644
index 0000000..377cc2f
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb
@@ -0,0 +1,33 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton::Handler
+
+ # @private
+ class CFlowController < Qpid::Proton::Handler::WrappedHandler
+
+ include Qpid::Proton::Util::Wrapper
+
+ def initialize(window = 1024)
+ super(Cproton.pn_flowcontroller(window))
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e5299b29/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 08e60b9..e14ff9d 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -86,6 +86,7 @@ require "handler/c_adaptor"
require "handler/wrapped_handler"
require "handler/acking"
require "handler/endpoint_state_handler"
+require "handler/c_flow_controller"
module Qpid::Proton
# @private
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org