You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2016/06/16 13:01:37 UTC

qpid-proton git commit: PROTON-1236: add a link to the transport's reactor as soon as the it is bound

Repository: qpid-proton
Updated Branches:
  refs/heads/master b005b877a -> 03b4ac609


PROTON-1236: add a link to the transport's reactor as soon as the it is bound

Previously the reactor would be put on the transport's attachment list
when a socket selector was created for the transport.  If the socket
setup fails then no selector is created and the reactor is never added
to the transport.  This would result in a crash as the code depends on
the reactor being present in the transport when transport events are
generated.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/03b4ac60
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/03b4ac60
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/03b4ac60

Branch: refs/heads/master
Commit: 03b4ac60932110ffe0352195add7667dc11a2875
Parents: b005b87
Author: Ken Giusti <kg...@apache.org>
Authored: Sat Jun 11 13:42:33 2016 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 16 08:42:39 2016 -0400

----------------------------------------------------------------------
 proton-c/src/reactor/connection.c |  4 +++-
 proton-c/src/tests/reactor.c      | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/03b4ac60/proton-c/src/reactor/connection.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/connection.c b/proton-c/src/reactor/connection.c
index 422a072..d73e386 100644
--- a/proton-c/src/reactor/connection.c
+++ b/proton-c/src/reactor/connection.c
@@ -134,6 +134,9 @@ void pni_handle_bound(pn_reactor_t *reactor, pn_event_t *event) {
   const char *port = "5672";
   pn_string_t *str = NULL;
 
+  // link the new transport to its reactor:
+  pni_record_init_reactor(pn_transport_attachments(transport), reactor);
+
   if (pn_connection_acceptor(conn) != NULL) {
       // this connection was created by the acceptor.  There is already a
       // socket assigned to this connection.  Nothing needs to be done.
@@ -310,7 +313,6 @@ pn_selectable_t *pn_reactor_selectable_transport(pn_reactor_t *reactor, pn_socke
   pn_record_t *tr = pn_transport_attachments(transport);
   pn_record_def(tr, PN_TRANCTX, PN_WEAKREF);
   pn_record_set(tr, PN_TRANCTX, sel);
-  pni_record_init_reactor(tr, reactor);
   pni_connection_update(sel);
   pn_reactor_update(reactor, sel);
   return sel;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/03b4ac60/proton-c/src/tests/reactor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/reactor.c b/proton-c/src/tests/reactor.c
index 427ffb5..900d6a3 100644
--- a/proton-c/src/tests/reactor.c
+++ b/proton-c/src/tests/reactor.c
@@ -372,6 +372,27 @@ static void test_reactor_connect(void) {
   pn_reactor_free(reactor);
 }
 
+static void test_reactor_bad_domain(void) {
+  pn_reactor_t *reactor = pn_reactor();
+  assert(reactor);
+  pn_handler_t *ch = pn_handler_new(client_dispatch, sizeof(client_t), NULL);
+  client_t *cli = cmem(ch);
+  cli->events = pn_list(PN_VOID, 0);
+  pn_connection_t *connection = pn_reactor_connection_to_host(reactor, "somebogusdomain", "5672", ch);
+  assert(connection);
+  pn_reactor_run(reactor);
+
+  expect(cli->events, PN_CONNECTION_INIT, PN_CONNECTION_LOCAL_OPEN,
+         PN_CONNECTION_BOUND, PN_TRANSPORT_TAIL_CLOSED,
+         PN_TRANSPORT_ERROR, PN_TRANSPORT_HEAD_CLOSED,
+         PN_TRANSPORT_CLOSED, PN_CONNECTION_UNBOUND,
+         END);
+
+  pn_free(cli->events);
+  pn_decref(ch);
+  pn_reactor_free(reactor);
+}
+
 typedef struct {
   int received;
 } sink_t;
@@ -541,6 +562,7 @@ int main(int argc, char **argv)
   test_reactor_handler_run_free();
   test_reactor_connection();
   test_reactor_connection_factory();
+  test_reactor_bad_domain();
   test_reactor_acceptor();
   test_reactor_acceptor_run();
   test_reactor_connect();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org