qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [1/3] qpid-proton git commit: check result of pn_connect and report error appropriately
Date Sun, 15 Feb 2015 17:23:02 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master db3d6e5fd -> 4867d7511


check result of pn_connect and report error appropriately


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

Branch: refs/heads/master
Commit: 9f51b1f1ff5b77c96b8261df9d45c33e36d20085
Parents: db3d6e5
Author: Rafael Schloming <rhs@alum.mit.edu>
Authored: Sun Feb 15 11:17:11 2015 -0500
Committer: Rafael Schloming <rhs@alum.mit.edu>
Committed: Sun Feb 15 11:17:11 2015 -0500

----------------------------------------------------------------------
 proton-c/src/reactor/connection.c  | 10 +++++++++-
 proton-c/src/transport/transport.c | 16 ++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f51b1f1/proton-c/src/reactor/connection.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/connection.c b/proton-c/src/reactor/connection.c
index da0eb22..dd6fe1c 100644
--- a/proton-c/src/reactor/connection.c
+++ b/proton-c/src/reactor/connection.c
@@ -125,8 +125,16 @@ void pni_handle_bound(pn_reactor_t *reactor, pn_event_t *event) {
     colon[0] = '\0';
   }
   pn_socket_t sock = pn_connect(pn_reactor_io(reactor), host, port);
-  pn_free(str);
   pn_transport_t *transport = pn_event_transport(event);
+  // invalid sockets are ignored by poll, so we need to do this manualy
+  if (sock == PN_INVALID_SOCKET) {
+    pn_condition_t *cond = pn_transport_condition(transport);
+    pn_condition_set_name(cond, "proton:connect");
+    pn_condition_set_description(cond, pn_error_text(pn_io_error(pn_reactor_io(reactor))));
+    pn_transport_close_tail(transport);
+    pn_transport_close_head(transport);
+  }
+  pn_free(str);
   pn_reactor_selectable_transport(reactor, sock, transport);
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9f51b1f1/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index c49044d..ba79f31 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -966,8 +966,20 @@ int pn_do_error(pn_transport_t *transport, const char *condition, const
char *fm
     transport->close_sent = true;
   }
   transport->halt = true;
-  pn_condition_set_name(&transport->condition, condition);
-  pn_condition_set_description(&transport->condition, buf);
+  pn_condition_t *cond = &transport->condition;
+  if (!pn_condition_is_set(cond)) {
+    pn_condition_set_name(cond, condition);
+    pn_condition_set_description(cond, buf);
+  } else {
+    const char *first = pn_condition_get_description(cond);
+    if (first) {
+      char extended[2048];
+      snprintf(extended, 2048, "%s (%s)", first, buf);
+      pn_condition_set_description(cond, extended);
+    } else {
+      pn_condition_set_description(cond, buf);
+    }
+  }
   pn_collector_t *collector = pni_transport_collector(transport);
   pn_collector_put(collector, PN_OBJECT, transport, PN_TRANSPORT_ERROR);
   if (transport->trace & PN_TRACE_DRV) {


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


Mime
View raw message