You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2016/05/25 12:46:29 UTC
qpid-dispatch git commit: DISPATCH-339 - [From Ganesh Murthy]
Properly handle default values for host/addr. This closes #78
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 6952d9f95 -> 87d0a406c
DISPATCH-339 - [From Ganesh Murthy] Properly handle default values for host/addr.
This closes #78
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/87d0a406
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/87d0a406
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/87d0a406
Branch: refs/heads/master
Commit: 87d0a406c64e6b4a94c009064c8526f1932fd846
Parents: 6952d9f
Author: Ted Ross <tr...@redhat.com>
Authored: Wed May 25 08:45:30 2016 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed May 25 08:45:30 2016 -0400
----------------------------------------------------------------------
src/connection_manager.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/87d0a406/src/connection_manager.c
----------------------------------------------------------------------
diff --git a/src/connection_manager.c b/src/connection_manager.c
index e208246..0e95067 100644
--- a/src/connection_manager.c
+++ b/src/connection_manager.c
@@ -29,6 +29,8 @@
#include <string.h>
#include <stdio.h>
+static char* HOST_ADDR_DEFAULT = "127.0.0.1";
+
struct qd_config_listener_t {
bool is_connector;
qd_bind_state_t state;
@@ -123,6 +125,30 @@ static void load_strip_annotations(qd_server_config_t *config, const char* strip
}
}
+/**
+ * Since both the host and the addr have defaults of 127.0.0.1, we will have to use the non-default wherever it is available.
+ */
+static void set_config_host(qd_server_config_t *config, qd_entity_t* entity)
+{
+ char *host = qd_entity_opt_string(entity, "host", 0);
+ char *addr = qd_entity_opt_string(entity, "addr", 0);
+
+ if (strcmp(host, HOST_ADDR_DEFAULT) == 0 && strcmp(addr, HOST_ADDR_DEFAULT) == 0) {
+ config->host = host;
+ }
+ else if (strcmp(host, addr) == 0) {
+ config->host = host;
+ }
+ else if (strcmp(host, HOST_ADDR_DEFAULT) == 0 && strcmp(addr, HOST_ADDR_DEFAULT) != 0) {
+ config->host = addr;
+ }
+ else if (strcmp(host, HOST_ADDR_DEFAULT) != 0 && strcmp(addr, HOST_ADDR_DEFAULT) == 0) {
+ config->host = host;
+ }
+
+ assert(config->host);
+}
+
static qd_error_t load_server_config(qd_dispatch_t *qd, qd_server_config_t *config, qd_entity_t* entity)
{
qd_error_clear();
@@ -149,11 +175,7 @@ static qd_error_t load_server_config(qd_dispatch_t *qd, qd_server_config_t *conf
config->link_capacity = qd_entity_opt_long(entity, "linkCapacity", 0); CHECK();
config->ssl_enabled = has_attrs(entity, ssl_attributes, ssl_attributes_count);
config->link_capacity = qd_entity_opt_long(entity, "linkCapacity", 0); CHECK();
- config->host = qd_entity_opt_string(entity, "host", 0); CHECK();
- if (! config->host) {
- config->host = qd_entity_opt_string(entity, "addr", 0); CHECK();
- }
- assert(config->host);
+ set_config_host(config, entity);
//
// Handle the defaults for link capacity.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org