summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorAsk Solem <ask@celeryproject.org>2014-04-14 17:31:29 +0100
committerAsk Solem <ask@celeryproject.org>2014-04-14 17:31:29 +0100
commit14141117b6e9036145b9c13816d58252613959c0 (patch)
treeb29c467b03444e6e3c97af855757db4b2da1a254 /Modules
parentd744fcacaadfeed0fda2df05f51c5f05e726b999 (diff)
downloadlibrabbitmq-14141117b6e9036145b9c13816d58252613959c0.tar.gz
Updated to use rabbitmq-c 0.5.0 and exposes Connection.server_properties
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_librabbitmq/connection.c22
-rw-r--r--Modules/_librabbitmq/connection.h3
2 files changed, 20 insertions, 5 deletions
diff --git a/Modules/_librabbitmq/connection.c b/Modules/_librabbitmq/connection.c
index 2125136..5fd289f 100644
--- a/Modules/_librabbitmq/connection.c
+++ b/Modules/_librabbitmq/connection.c
@@ -6,6 +6,7 @@
#include <sys/time.h>
#include <amqp.h>
+#include <amqp_tcp_socket.h>
#include "connection.h"
#include "distmeta.h"
@@ -761,7 +762,7 @@ int PyRabbitMQ_HandleAMQError(PyRabbitMQ_Connection *self, unsigned int channel,
snprintf(errorstr, sizeof(errorstr), "%s: %s",
context,
reply.library_error
- ? amqp_error_string(reply.library_error)
+ ? amqp_error_string2(reply.library_error)
: "(end-of-stream)");
goto connerror;
@@ -848,6 +849,7 @@ PyRabbitMQ_ConnectionType_new(PyTypeObject *type,
self->port = 5672;
self->sockfd = 0;
self->connected = 0;
+ self->server_properties = NULL;
self->callbacks = NULL;
}
return self;
@@ -863,6 +865,7 @@ PyRabbitMQ_ConnectionType_dealloc(PyRabbitMQ_Connection *self)
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject*)self);
Py_XDECREF(self->callbacks);
+ Py_XDECREF(self->server_properties);
self->ob_type->tp_free(self);
}
@@ -910,8 +913,8 @@ PyRabbitMQ_ConnectionType_init(PyRabbitMQ_Connection *self,
self->heartbeat = heartbeat;
self->weakreflist = NULL;
self->callbacks = PyDict_New();
- if (self->callbacks == NULL)
- return -1;
+ if (self->callbacks == NULL) return -1;
+ self->server_properties = NULL;
return 0;
}
@@ -933,6 +936,8 @@ PyRabbitMQ_Connection_fileno(PyRabbitMQ_Connection *self)
static PyObject*
PyRabbitMQ_Connection_connect(PyRabbitMQ_Connection *self)
{
+ int status;
+ amqp_socket_t *socket = NULL;
amqp_rpc_reply_t reply;
if (self->connected) {
@@ -941,13 +946,19 @@ PyRabbitMQ_Connection_connect(PyRabbitMQ_Connection *self)
}
Py_BEGIN_ALLOW_THREADS;
self->conn = amqp_new_connection();
- self->sockfd = amqp_open_socket(self->hostname, self->port);
+ socket = amqp_tcp_socket_new(self->conn);
+ Py_END_ALLOW_THREADS;
+
+ if (!socket) goto error;
+ Py_BEGIN_ALLOW_THREADS;
+ status = amqp_socket_open(socket, self->hostname, self->port);
Py_END_ALLOW_THREADS;
+ if (status) goto error;
if (!PyRabbitMQ_HandleError(self->sockfd, "Error opening socket"))
goto error;
Py_BEGIN_ALLOW_THREADS;
- amqp_set_sockfd(self->conn, self->sockfd);
+ self->sockfd = amqp_socket_get_sockfd(socket);
reply = amqp_login(self->conn, self->virtual_host, self->channel_max,
self->frame_max, self->heartbeat,
AMQP_SASL_METHOD_PLAIN, self->userid, self->password);
@@ -960,6 +971,7 @@ PyRabbitMQ_Connection_connect(PyRabbitMQ_Connection *self)
self->channel_max = self->conn->channel_max;
self->frame_max = self->conn->frame_max;
self->heartbeat = self->conn->heartbeat;
+ self->server_properties = AMQTable_toPyDict(amqp_get_server_properties(self->conn));
Py_RETURN_NONE;
error:
PyRabbitMQ_Connection_close(self);
diff --git a/Modules/_librabbitmq/connection.h b/Modules/_librabbitmq/connection.h
index da67b46..d4dc6c7 100644
--- a/Modules/_librabbitmq/connection.h
+++ b/Modules/_librabbitmq/connection.h
@@ -140,6 +140,7 @@ typedef struct {
int sockfd;
int connected;
+ PyObject *server_properties;
PyObject *callbacks; /* {channel_id: {consumer_tag:callback}} */
PyObject *weakreflist;
@@ -244,6 +245,8 @@ static PyMemberDef PyRabbitMQ_ConnectionType_members[] = {
offsetof(PyRabbitMQ_Connection, port), READONLY, NULL},
{"heartbeat", T_INT,
offsetof(PyRabbitMQ_Connection, heartbeat), READONLY, NULL},
+ {"server_properties", T_OBJECT_EX,
+ offsetof(PyRabbitMQ_Connection, server_properties), READONLY, NULL},
{"connected", T_INT,
offsetof(PyRabbitMQ_Connection, connected), READONLY, NULL},
{"channel_max", T_INT,