qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [1/2] qpid-proton git commit: PROTON-1403: C proactor examples default to explicit IPv4
Date Mon, 20 Feb 2017 20:49:38 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master d5c0152a7 -> 6b6dd8699


PROTON-1403: C proactor examples default to explicit IPv4

Use explicit IPv4 addresses to make the C examples interop more smoothly by
default with other examples, qpid-dispatch and other brokers. Command line
options still allow IPv6 addresses


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

Branch: refs/heads/master
Commit: 31a3c99e811d33e9baef362e322605152e4e91aa
Parents: d5c0152
Author: Alan Conway <aconway@redhat.com>
Authored: Fri Feb 17 17:35:22 2017 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon Feb 20 15:11:00 2017 -0500

----------------------------------------------------------------------
 examples/c/proactor/broker.c  | 12 +++++++-----
 examples/c/proactor/direct.c  | 13 ++++++++-----
 examples/c/proactor/receive.c | 11 ++++++++---
 examples/c/proactor/send.c    | 11 ++++++++---
 4 files changed, 31 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31a3c99e/examples/c/proactor/broker.c
----------------------------------------------------------------------
diff --git a/examples/c/proactor/broker.c b/examples/c/proactor/broker.c
index 2a338e1..a7d8863 100644
--- a/examples/c/proactor/broker.c
+++ b/examples/c/proactor/broker.c
@@ -462,12 +462,14 @@ int main(int argc, char **argv) {
   broker_init(&b, container_id, nthreads, heartbeat);
 
   /* Parse the URL or use default values */
+  const char *host = "0.0.0.0";
+  const char *port = "amqp";
   pn_url_t *url = urlstr ? pn_url_parse(urlstr) : NULL;
-  /* Listen on IPv6 wildcard. On systems that do not set IPV6ONLY by default,
-     this will also listen for mapped IPv4 on the same port.
-  */
-  const char *host = url ? pn_url_get_host(url) : "::";
-  const char *port = url ? pn_url_get_port(url) : "amqp";
+  if (url) {
+    if (pn_url_get_host(url)) host = pn_url_get_host(url);
+    if (pn_url_get_port(url)) port = (pn_url_get_port(url));
+  }
+
   pn_proactor_listen(b.proactor, pn_listener(), host, port, 16);
   printf("listening on '%s:%s' %zd threads\n", host, port, b.threads);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31a3c99e/examples/c/proactor/direct.c
----------------------------------------------------------------------
diff --git a/examples/c/proactor/direct.c b/examples/c/proactor/direct.c
index 3d0a7d1..de2d6aa 100644
--- a/examples/c/proactor/direct.c
+++ b/examples/c/proactor/direct.c
@@ -331,12 +331,15 @@ int main(int argc, char **argv) {
   snprintf(app.container_id, sizeof(app.container_id), "%s", argv[0]);
 
   /* Parse the URL or use default values */
+  const char *host = "0.0.0.0";
+  const char *port = "amqp";
+  strncpy(app.address, "example", sizeof(app.address));
   pn_url_t *url = urlstr ? pn_url_parse(urlstr) : NULL;
-  /* Listen on IPv6 wildcard. On systems that do not set IPV6ONLY by default,
-     this will also listen for mapped IPv4 on the same port.
-  */
-  const char *host = url ? pn_url_get_host(url) : "::";
-  const char *port = url ? pn_url_get_port(url) : "amqp";
+  if (url) {
+    if (pn_url_get_host(url)) host = pn_url_get_host(url);
+    if (pn_url_get_port(url)) port = (pn_url_get_port(url));
+    if (pn_url_get_path(url)) strncpy(app.address, pn_url_get_path(url), sizeof(app.address));
+  }
 
   app.proactor = pn_proactor();
   pn_proactor_listen(app.proactor, pn_listener(), host, port, 16);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31a3c99e/examples/c/proactor/receive.c
----------------------------------------------------------------------
diff --git a/examples/c/proactor/receive.c b/examples/c/proactor/receive.c
index 1bc5509..65ec069 100644
--- a/examples/c/proactor/receive.c
+++ b/examples/c/proactor/receive.c
@@ -180,10 +180,15 @@ int main(int argc, char **argv) {
   snprintf(app.container_id, sizeof(app.container_id), "%s", argv[0]);
 
   /* Parse the URL or use default values */
+  const char *host = "127.0.0.1";
+  const char *port = "amqp";
+  strncpy(app.address, "example", sizeof(app.address));
   pn_url_t *url = urlstr ? pn_url_parse(urlstr) : NULL;
-  const char *host = url ? pn_url_get_host(url) : NULL;
-  const char *port = url ? pn_url_get_port(url) : "amqp";
-  strncpy(app.address, (url && pn_url_get_path(url)) ? pn_url_get_path(url) : "example",
sizeof(app.address));
+  if (url) {
+    if (pn_url_get_host(url)) host = pn_url_get_host(url);
+    if (pn_url_get_port(url)) port = (pn_url_get_port(url));
+    if (pn_url_get_path(url)) strncpy(app.address, pn_url_get_path(url), sizeof(app.address));
+  }
 
   /* Create the proactor and connect */
   app.proactor = pn_proactor();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31a3c99e/examples/c/proactor/send.c
----------------------------------------------------------------------
diff --git a/examples/c/proactor/send.c b/examples/c/proactor/send.c
index bba5d3e..0786f19 100644
--- a/examples/c/proactor/send.c
+++ b/examples/c/proactor/send.c
@@ -209,10 +209,15 @@ int main(int argc, char **argv) {
   snprintf(app.container_id, sizeof(app.container_id), "%s", argv[0]);
 
   /* Parse the URL or use default values */
+  const char *host = "127.0.0.1";
+  const char *port = "amqp";
+  strncpy(app.address, "example", sizeof(app.address));
   pn_url_t *url = urlstr ? pn_url_parse(urlstr) : NULL;
-  const char *host = url ? pn_url_get_host(url) : NULL;
-  const char *port = url ? pn_url_get_port(url) : "amqp";
-  strncpy(app.address, (url && pn_url_get_path(url)) ? pn_url_get_path(url) : "example",
sizeof(app.address));
+  if (url) {
+    if (pn_url_get_host(url)) host = pn_url_get_host(url);
+    if (pn_url_get_port(url)) port = (pn_url_get_port(url));
+    if (pn_url_get_path(url)) strncpy(app.address, pn_url_get_path(url), sizeof(app.address));
+  }
 
   /* Create the proactor and connect */
   app.proactor = pn_proactor();


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


Mime
View raw message