diff options
| author | Ted Ross <tross@apache.org> | 2013-10-04 13:40:59 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2013-10-04 13:40:59 +0000 |
| commit | 28302f5604920d7cf7941481ff376f92cdd0e535 (patch) | |
| tree | 3f7e2686d87cb713f7be84f46c5b4d7eb027c116 /qpid/extras/dispatch/src/python_embedded.c | |
| parent | 20fbc65eba57a9526a39652cb1473a8551d3d97b (diff) | |
| download | qpid-python-28302f5604920d7cf7941481ff376f92cdd0e535.tar.gz | |
QPID-4967 - Work in progress on multi-router networks
- Added a feature to the hash table to allow referenced objects to hold a direct linkage
back to the hash structure for fast deletion and access to the key. This allows the key
to be stored in only one place and allows items to be removed without requiring a hash
lookup on the key.
- Completed the integration of the Python router and the C data structures that track
remote routers (neighbor and multi-hop).
- Allow multiple addresses in the ioAdapter from Python.
- Added a separate address for the hello messages because the messaging pattern is different
for these messages.
- Added some content to the TODO file.
- Added test configurations for a two-router network.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1529163 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/extras/dispatch/src/python_embedded.c')
| -rw-r--r-- | qpid/extras/dispatch/src/python_embedded.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/qpid/extras/dispatch/src/python_embedded.c b/qpid/extras/dispatch/src/python_embedded.c index a3c41f86f5..c7c8f82dfc 100644 --- a/qpid/extras/dispatch/src/python_embedded.c +++ b/qpid/extras/dispatch/src/python_embedded.c @@ -398,7 +398,8 @@ typedef struct { PyObject *handler; PyObject *handler_rx_call; dx_dispatch_t *dx; - dx_address_t *address; + Py_ssize_t addr_count; + dx_address_t **addrs; } IoAdapter; @@ -469,25 +470,35 @@ static void dx_io_rx_handler(void *context, dx_message_t *msg, int link_id) static int IoAdapter_init(IoAdapter *self, PyObject *args, PyObject *kwds) { - const char *address; - if (!PyArg_ParseTuple(args, "Os", &self->handler, &address)) + PyObject *addrs; + if (!PyArg_ParseTuple(args, "OO", &self->handler, &addrs)) return -1; self->handler_rx_call = PyObject_GetAttrString(self->handler, "receive"); if (!self->handler_rx_call || !PyCallable_Check(self->handler_rx_call)) return -1; + if (!PyTuple_Check(addrs)) + return -1; + Py_INCREF(self->handler); Py_INCREF(self->handler_rx_call); - self->dx = dispatch; - self->address = dx_router_register_address(self->dx, address, dx_io_rx_handler, self); + self->dx = dispatch; + self->addr_count = PyTuple_Size(addrs); + self->addrs = NEW_PTR_ARRAY(dx_address_t, self->addr_count); + for (Py_ssize_t idx = 0; idx < self->addr_count; idx++) + self->addrs[idx] = dx_router_register_address(self->dx, + PyString_AS_STRING(PyTuple_GetItem(addrs, idx)), + dx_io_rx_handler, self); return 0; } static void IoAdapter_dealloc(IoAdapter* self) { - dx_router_unregister_address(self->address); + for (Py_ssize_t idx = 0; idx < self->addr_count; idx++) + dx_router_unregister_address(self->addrs[idx]); + free(self->addrs); Py_DECREF(self->handler); Py_DECREF(self->handler_rx_call); self->ob_type->tp_free((PyObject*)self); |
