Repository: qpid-proton
Updated Branches:
  refs/heads/master 817609a54 -> d4241caa0


PROTON-1781 [c-proactor] fix mis-named netaddr functions

The old functions are deprecated but still present - old binaries can still be
linked with new libraies, old source will fail to compile with a deprecation
message unless -DPN_USE_DEPRECATED_API is present in CMAKE_C_FLAGS


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

Branch: refs/heads/master
Commit: 06c3d6e2f46811038853b95401cd017cb21e2713
Parents: 817609a
Author: Alan Conway <acon...@redhat.com>
Authored: Fri Mar 2 16:51:27 2018 -0500
Committer: Alan Conway <acon...@redhat.com>
Committed: Fri Mar 2 16:51:27 2018 -0500

----------------------------------------------------------------------
 examples/c/broker.c                       |  2 +-
 examples/c/direct.c                       |  2 +-
 proton-c/bindings/cpp/src/listener.cpp    |  2 +-
 proton-c/include/proton/import_export.h   | 14 ++++++++++++++
 proton-c/include/proton/netaddr.h         | 15 ++++++++++++---
 proton-c/src/proactor/epoll.c             |  6 +++---
 proton-c/src/proactor/libuv.c             |  6 +++---
 proton-c/src/proactor/proactor-internal.c |  5 +++++
 proton-c/src/proactor/win_iocp.c          |  6 +++---
 proton-c/src/tests/proactor.c             | 12 ++++++------
 10 files changed, 49 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/examples/c/broker.c
----------------------------------------------------------------------
diff --git a/examples/c/broker.c b/examples/c/broker.c
index 3257cec..23a91b1 100644
--- a/examples/c/broker.c
+++ b/examples/c/broker.c
@@ -290,7 +290,7 @@ static void handle(broker_t* b, pn_event_t* e) {
 
    case PN_LISTENER_OPEN: {
      char port[256];             /* Get the listening port */
-     pn_netaddr_host_port(pn_netaddr_listening(pn_event_listener(e)), NULL, 0, 
port, sizeof(port));
+     pn_netaddr_host_port(pn_listener_addr(pn_event_listener(e)), NULL, 0, 
port, sizeof(port));
      printf("listening on %s\n", port);
      fflush(stdout);
      break;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/examples/c/direct.c
----------------------------------------------------------------------
diff --git a/examples/c/direct.c b/examples/c/direct.c
index 9ecda7c..6d8642c 100644
--- a/examples/c/direct.c
+++ b/examples/c/direct.c
@@ -231,7 +231,7 @@ static bool handle(app_data_t* app, pn_event_t* event) {
 
    case PN_LISTENER_OPEN: {
      char port[256];             /* Get the listening port */
-     pn_netaddr_host_port(pn_netaddr_listening(pn_event_listener(event)), 
NULL, 0, port, sizeof(port));
+     pn_netaddr_host_port(pn_listener_addr(pn_event_listener(event)), NULL, 0, 
port, sizeof(port));
      printf("listening on %s\n", port);
      fflush(stdout);
      break;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/bindings/cpp/src/listener.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/listener.cpp 
b/proton-c/bindings/cpp/src/listener.cpp
index 4788b6a..b62d171 100644
--- a/proton-c/bindings/cpp/src/listener.cpp
+++ b/proton-c/bindings/cpp/src/listener.cpp
@@ -41,7 +41,7 @@ void listener::stop() { if (listener_) 
pn_listener_close(listener_); }
 
 int listener::port() {
     char port[16] = "";
-    pn_netaddr_host_port(pn_netaddr_listening(listener_), NULL, 0, port, 
sizeof(port));
+    pn_netaddr_host_port(pn_listener_addr(listener_), NULL, 0, port, 
sizeof(port));
     int i = atoi(port);
     if (!i) throw error("listener has no port");
     return i;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/include/proton/import_export.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/import_export.h 
b/proton-c/include/proton/import_export.h
index ee09132..14e6b82 100644
--- a/proton-c/include/proton/import_export.h
+++ b/proton-c/include/proton/import_export.h
@@ -65,6 +65,20 @@
 #  define PNX_EXTERN PN_IMPORT
 #endif
 
+#if ! defined(PN_USE_DEPRECATED_API)
+#  if defined(WIN32)
+#    define PN_DEPRECATED(message) __declspec(deprecated(message))
+#  elif defined __GNUC__
+#    if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40500
+#      define PN_DEPRECATED(message) __attribute__((deprecated))
+#    else
+#      define PN_DEPRECATED(message) __attribute__((deprecated(message)))
+#    endif
+#  endif
+#endif
+#ifndef PN_DEPRECATED
+#  define  PN_DEPRECATED(message)
+#endif
 /**
  * @endcond
  */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/include/proton/netaddr.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/netaddr.h 
b/proton-c/include/proton/netaddr.h
index ffc9c6a..13fcdee 100644
--- a/proton-c/include/proton/netaddr.h
+++ b/proton-c/include/proton/netaddr.h
@@ -53,13 +53,13 @@ PNP_EXTERN int pn_netaddr_str(const pn_netaddr_t *addr, 
char *buf, size_t size);
  * Get the local address of a transport. Return `NULL` if not available.
  * Pointer is invalid after the transport closes (PN_TRANSPORT_CLOSED event is 
handled)
  */
-PNP_EXTERN const pn_netaddr_t *pn_netaddr_local(pn_transport_t *t);
+PNP_EXTERN const pn_netaddr_t *pn_transport_local_addr(pn_transport_t *t);
 
 /**
  * Get the local address of a transport. Return `NULL` if not available.
  * Pointer is invalid after the transport closes (PN_TRANSPORT_CLOSED event is 
handled)
  */
-PNP_EXTERN const pn_netaddr_t *pn_netaddr_remote(pn_transport_t *t);
+PNP_EXTERN const pn_netaddr_t *pn_transport_remote_addr(pn_transport_t *t);
 
 /**
  * Get the listening addresses of a listener.
@@ -77,7 +77,7 @@ PNP_EXTERN const pn_netaddr_t 
*pn_netaddr_remote(pn_transport_t *t);
  * Use pn_netaddr_next() to iterate over the list.
  * Pointer is invalid after the listener closes (PN_LISTENER_CLOSED event is 
handled)
  */
-PNP_EXTERN const pn_netaddr_t *pn_netaddr_listening(pn_listener_t *l);
+PNP_EXTERN const pn_netaddr_t *pn_listener_addr(pn_listener_t *l);
 
 /**
  * @return Pointer to the next address in a list of addresses, NULL if at the 
end of the list or
@@ -105,6 +105,15 @@ PNP_EXTERN size_t pn_netaddr_socklen(const pn_netaddr_t 
*na);
  */
 PNP_EXTERN int pn_netaddr_host_port(const pn_netaddr_t* na, char *host, size_t 
hlen, char *port, size_t plen);
 
+/**  @deprecated @{ */
+PN_DEPRECATED("use pn_transport_local_addr")
+PNP_EXTERN const pn_netaddr_t *pn_netaddr_local(pn_transport_t *t);
+PN_DEPRECATED("use pn_transport_remote_addr()")
+PNP_EXTERN const pn_netaddr_t *pn_netaddr_remote(pn_transport_t *t);
+PN_DEPRECATED("use pn_listener_addr()")
+PNP_EXTERN const pn_netaddr_t *pn_netaddr_listening(pn_listener_t *l);
+/** @} */
+
 /**
  * @}
  */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index 483173a..8ff5831 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -2196,17 +2196,17 @@ void pn_proactor_disconnect(pn_proactor_t *p, 
pn_condition_t *cond) {
     wake_notify(&p->context);
 }
 
-const pn_netaddr_t *pn_netaddr_local(pn_transport_t *t) {
+const pn_netaddr_t *pn_transport_local_addr(pn_transport_t *t) {
   pconnection_t *pc = get_pconnection(pn_transport_connection(t));
   return pc? &pc->local : NULL;
 }
 
-const pn_netaddr_t *pn_netaddr_remote(pn_transport_t *t) {
+const pn_netaddr_t *pn_transport_remote_addr(pn_transport_t *t) {
   pconnection_t *pc = get_pconnection(pn_transport_connection(t));
   return pc ? &pc->remote : NULL;
 }
 
-const pn_netaddr_t *pn_netaddr_listening(pn_listener_t *l) {
+const pn_netaddr_t *pn_listener_addr(pn_listener_t *l) {
   return l->acceptors_size > 0 ? &l->acceptors[0].addr : NULL;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/src/proactor/libuv.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c
index 9329967..b542b20 100644
--- a/proton-c/src/proactor/libuv.c
+++ b/proton-c/src/proactor/libuv.c
@@ -1324,17 +1324,17 @@ void pn_listener_accept2(pn_listener_t *l, 
pn_connection_t *c, pn_transport_t *t
   work_notify(&l->work);
 }
 
-const pn_netaddr_t *pn_netaddr_local(pn_transport_t *t) {
+const pn_netaddr_t *pn_transport_local_addr(pn_transport_t *t) {
   pconnection_t *pc = get_pconnection(pn_transport_connection(t));
   return pc? &pc->local : NULL;
 }
 
-const pn_netaddr_t *pn_netaddr_remote(pn_transport_t *t) {
+const pn_netaddr_t *pn_transport_remote_addr(pn_transport_t *t) {
   pconnection_t *pc = get_pconnection(pn_transport_connection(t));
   return pc ? &pc->remote : NULL;
 }
 
-const pn_netaddr_t *pn_netaddr_listening(pn_listener_t *l) {
+const pn_netaddr_t *pn_listener_addr(pn_listener_t *l) {
   return l->addrs ? &l->addrs[0] : NULL;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/src/proactor/proactor-internal.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/proactor-internal.c 
b/proton-c/src/proactor/proactor-internal.c
index 6d96fee..8c53785 100644
--- a/proton-c/src/proactor/proactor-internal.c
+++ b/proton-c/src/proactor/proactor-internal.c
@@ -23,6 +23,7 @@
 #include "proactor-internal.h"
 #include <proton/error.h>
 #include <proton/listener.h>
+#include <proton/netaddr.h>
 #include <proton/proactor.h>
 
 #include <stdio.h>
@@ -96,4 +97,8 @@ void pn_listener_accept(pn_listener_t *l, pn_connection_t *c) 
{
   pn_listener_accept2(l, c, NULL);
 }
 
+/* Deprecated, keep backwards compatible library symbols */
+const pn_netaddr_t *pn_netaddr_local(pn_transport_t *t) { return 
pn_transport_local_addr(t); }
+const pn_netaddr_t *pn_netaddr_remote(pn_transport_t *t) { return 
pn_transport_remote_addr(t); }
+const pn_netaddr_t *pn_netaddr_listening(pn_listener_t *l) { return 
pn_listener_addr(l); }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/src/proactor/win_iocp.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/win_iocp.c b/proton-c/src/proactor/win_iocp.c
index fe09876..e41ac5b 100644
--- a/proton-c/src/proactor/win_iocp.c
+++ b/proton-c/src/proactor/win_iocp.c
@@ -3404,17 +3404,17 @@ void pn_proactor_disconnect(pn_proactor_t *p, 
pn_condition_t *cond) {
   }
 }
 
-const pn_netaddr_t *pn_netaddr_local(pn_transport_t *t) {
+const pn_netaddr_t *pn_transport_local_addr(pn_transport_t *t) {
   pconnection_t *pc = get_pconnection(pn_transport_connection(t));
   return pc? &pc->local : NULL;
 }
 
-const pn_netaddr_t *pn_netaddr_remote(pn_transport_t *t) {
+const pn_netaddr_t *pn_transport_remote_addr(pn_transport_t *t) {
   pconnection_t *pc = get_pconnection(pn_transport_connection(t));
   return pc ? &pc->remote : NULL;
 }
 
-const pn_netaddr_t *pn_netaddr_listening(pn_listener_t *l) {
+const pn_netaddr_t *pn_listener_addr(pn_listener_t *l) {
   return l->psockets ? &l->psockets[0].listen_addr : NULL;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06c3d6e2/proton-c/src/tests/proactor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/proactor.c b/proton-c/src/tests/proactor.c
index a9eef18..97f1dee 100644
--- a/proton-c/src/tests/proactor.c
+++ b/proton-c/src/tests/proactor.c
@@ -144,7 +144,7 @@ struct addrinfo {
 
 struct addrinfo listener_info(pn_listener_t *l) {
   struct addrinfo ai = {{0}};
-  const pn_netaddr_t *na = pn_netaddr_listening(l);
+  const pn_netaddr_t *na = pn_listener_addr(l);
   TEST_ASSERT(0 == pn_netaddr_host_port(na, ai.host, sizeof(ai.host), ai.port, 
sizeof(ai.port)));
   for (na = pn_netaddr_next(na); na; na = pn_netaddr_next(na)) { /* Check that 
ports are consistent */
     char port[MAX_STR];
@@ -880,7 +880,7 @@ static void test_netaddr(test_t *t) {
   char cr[1024], cl[1024], sr[1024], sl[1024];
 
   pn_transport_t *ct = pn_connection_transport(c);
-  const pn_netaddr_t *na = pn_netaddr_remote(ct);
+  const pn_netaddr_t *na = pn_transport_remote_addr(ct);
   pn_netaddr_str(na, cr, sizeof(cr));
   TEST_STR_IN(t, listener_info(l).port, cr); /* remote address has listening 
port */
 
@@ -888,11 +888,11 @@ static void test_netaddr(test_t *t) {
 
   pn_transport_t *st = pn_connection_transport(s);
   if (!TEST_CHECK(t, st)) return;
-  pn_netaddr_str(pn_netaddr_local(st), sl, sizeof(sl));
+  pn_netaddr_str(pn_transport_local_addr(st), sl, sizeof(sl));
   TEST_STR_EQUAL(t, cr, sl);  /* client remote == server local */
 
-  pn_netaddr_str(pn_netaddr_local(ct), cl, sizeof(cl));
-  pn_netaddr_str(pn_netaddr_remote(st), sr, sizeof(sr));
+  pn_netaddr_str(pn_transport_local_addr(ct), cl, sizeof(cl));
+  pn_netaddr_str(pn_transport_remote_addr(st), sr, sizeof(sr));
   TEST_STR_EQUAL(t, cl, sr);    /* client local == server remote */
 
   char host[MAX_STR] = "";
@@ -903,7 +903,7 @@ static void test_netaddr(test_t *t) {
   TEST_STR_EQUAL(t, listener_info(l).port, serv);
 
   /* Make sure you can use NULL, 0 to get length of address string without a 
crash */
-  size_t len = pn_netaddr_str(pn_netaddr_local(ct), NULL, 0);
+  size_t len = pn_netaddr_str(pn_transport_local_addr(ct), NULL, 0);
   TEST_CHECKF(t, strlen(cl) == len, "%d != %d", strlen(cl), len);
 
   TEST_PROACTORS_DRAIN(tps);


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

Reply via email to