You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2016/06/13 14:22:14 UTC
qpid-dispatch git commit: DISPATCH-381 - Allow integer values to be
specified in connection properties. Regression caused by fix to issue
DISPATCH-211
Repository: qpid-dispatch
Updated Branches:
refs/heads/master c98df309f -> ea44b20d6
DISPATCH-381 - Allow integer values to be specified in connection properties. Regression caused by fix to issue DISPATCH-211
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/ea44b20d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/ea44b20d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/ea44b20d
Branch: refs/heads/master
Commit: ea44b20d63622db68a43ca072a3534ff05ec942c
Parents: c98df30
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Mon Jun 13 10:21:14 2016 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Mon Jun 13 10:21:14 2016 -0400
----------------------------------------------------------------------
src/entity.c | 31 ++++++++++++++++++++++++++++++-
src/entity.h | 4 +++-
src/server.c | 22 +++++++++++++++-------
tests/system_tests_one_router.py | 4 ++--
4 files changed, 50 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea44b20d/src/entity.c
----------------------------------------------------------------------
diff --git a/src/entity.c b/src/entity.c
index 065dd74..3c0d83a 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -168,8 +168,37 @@ qd_error_t qd_entity_set_map(qd_entity_t *entity, const char *attribute) {
return qd_entity_set_py(entity, attribute, PyDict_New());
}
-qd_error_t qd_entity_set_map_key_value(qd_entity_t *entity, const char *attribute, const char *key, const char *value)
+qd_error_t qd_entity_set_map_key_value_int(qd_entity_t *entity, const char *attribute, const char *key, int value)
{
+ if (!key)
+ return QD_ERROR_VALUE;
+
+ PyObject *py_key = PyString_FromString(key);
+ PyObject *py_value = PyInt_FromLong(value);
+ PyObject *py_attribute = PyString_FromString(attribute);
+
+ qd_error_t ret = QD_ERROR_NONE;
+
+ if (PyDict_Contains((PyObject*)entity, py_attribute) == 1) {
+ PyObject* dict = PyDict_GetItem((PyObject*)entity, py_attribute);
+ if (PyDict_SetItem(dict, py_key, py_value) < 0)
+ ret = QD_ERROR_PYTHON;
+ }
+ else
+ ret = QD_ERROR_VALUE;
+
+ Py_XDECREF(py_key);
+ Py_XDECREF(py_value);
+ Py_XDECREF(py_attribute);
+
+ return ret;
+}
+
+qd_error_t qd_entity_set_map_key_value_string(qd_entity_t *entity, const char *attribute, const char *key, const char *value)
+{
+ if (!key)
+ return QD_ERROR_VALUE;
+
PyObject *py_key = PyString_FromString(key);
PyObject *py_value = PyString_FromString(value);
PyObject *py_attribute = PyString_FromString(attribute);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea44b20d/src/entity.h
----------------------------------------------------------------------
diff --git a/src/entity.h b/src/entity.h
index 0b54c2c..fda51c6 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -108,7 +108,9 @@ qd_error_t qd_entity_set_map(qd_entity_t *entity, const char *attribute);
* - QD_ERROR_PYTHON if there was an error from the Python side when setting the key/value error
* - QD_ERROR_VALUE if a non-dictionary attribute was specified
*/
-qd_error_t qd_entity_set_map_key_value(qd_entity_t *entity, const char *attribute, const char *key, const char *value);
+qd_error_t qd_entity_set_map_key_value_string(qd_entity_t *entity, const char *attribute, const char *key, const char *value);
+
+qd_error_t qd_entity_set_map_key_value_int(qd_entity_t *entity, const char *attribute, const char *key, int value);
/// @}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea44b20d/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index f9bec0b..55e2ea9 100644
--- a/src/server.c
+++ b/src/server.c
@@ -337,7 +337,7 @@ void qd_connection_set_user(qd_connection_t *conn)
}
-static void qd_get_next_pn_data(pn_data_t *data, const char **d)
+static void qd_get_next_pn_data(pn_data_t *data, const char **d, int *d1)
{
if (pn_data_next(data)) {
switch (pn_data_type(data)) {
@@ -347,6 +347,9 @@ static void qd_get_next_pn_data(pn_data_t *data, const char **d)
case PN_SYMBOL:
*d = pn_data_get_symbol(data).start;
break;
+ case PN_INT:
+ *d1 = pn_data_get_int(data);
+ break;
default:
break;
}
@@ -375,12 +378,17 @@ static qd_error_t qd_set_connection_properties(qd_entity_t* entity, qd_connectio
for (size_t i = 0; i < count/2; i++) {
const char *key = 0;
- qd_get_next_pn_data(data, &key);
- const char *value = 0;
- qd_get_next_pn_data(data, &value);
-
- // Now we have a key and value
- error_t = qd_entity_set_map_key_value(entity, props, key, value);
+ // We are assuming for now that all keys are strings
+ qd_get_next_pn_data(data, &key, 0);
+ const char *value_string = 0;
+ int value_int = 0;
+ // We are assuming for now that all values are either strings or integers
+ qd_get_next_pn_data(data, &value_string, &value_int);
+
+ if (value_string)
+ error_t = qd_entity_set_map_key_value_string(entity, props, key, value_string);
+ else if (value_int)
+ error_t = qd_entity_set_map_key_value_int(entity, props, key, value_int);
if (error_t != QD_ERROR_NONE)
return error_t;
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea44b20d/tests/system_tests_one_router.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_one_router.py b/tests/system_tests_one_router.py
index 6b6dd6c..26a4926 100644
--- a/tests/system_tests_one_router.py
+++ b/tests/system_tests_one_router.py
@@ -25,7 +25,7 @@ from proton.reactor import Container, AtMostOnce, AtLeastOnce
from proton.utils import BlockingConnection, SyncRequestResponse
from qpid_dispatch.management.client import Node
-CONNECTION_PROPERTIES={u'connection': u'properties'}
+CONNECTION_PROPERTIES = {u'connection': u'properties', u'int_property': 6451}
class RouterTest(TestCase):
"""System tests involving a single router"""
@@ -1079,7 +1079,7 @@ class RouterTest(TestCase):
node = Node.connect(self.router.addresses[0])
- results = [[{u'connection': u'properties'}], [{}]]
+ results = [[{u'connection': u'properties', u'int_property': 6451}], [{}]]
self.assertEqual(node.query(type='org.apache.qpid.dispatch.connection', attribute_names=['properties']).results,
results)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org