summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_api.c
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonygarnockjones@gmail.com>2010-02-18 17:17:56 +1300
committerTony Garnock-Jones <tonygarnockjones@gmail.com>2010-02-18 17:17:56 +1300
commit5568ccff3edef70041e45910077ed0ee17a435d7 (patch)
treec1e8dda5b2a10b26f0fa6183b85c4e9398fd276b /librabbitmq/amqp_api.c
parentcff07546f5ba7ad50436fa4e45a05093650feecc (diff)
downloadrabbitmq-c-github-ask-5568ccff3edef70041e45910077ed0ee17a435d7.tar.gz
Remove amqp_rpc_reply global variable, making it instead state-local
and accessible only through amqp_get_rpc_reply(). Add a better comment on amqp_get_rpc_reply() to be a little clearer about when it's inappropriate to use it.
Diffstat (limited to 'librabbitmq/amqp_api.c')
-rw-r--r--librabbitmq/amqp_api.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/librabbitmq/amqp_api.c b/librabbitmq/amqp_api.c
index 1d329e0..7cb865d 100644
--- a/librabbitmq/amqp_api.c
+++ b/librabbitmq/amqp_api.c
@@ -10,17 +10,15 @@
#include <assert.h>
-amqp_rpc_reply_t amqp_rpc_reply;
-
-#define RPC_REPLY(replytype) \
- (amqp_rpc_reply.reply_type == AMQP_RESPONSE_NORMAL \
- ? (replytype *) amqp_rpc_reply.reply.decoded \
+#define RPC_REPLY(replytype) \
+ (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL \
+ ? (replytype *) state->most_recent_api_result.reply.decoded \
: NULL)
amqp_channel_open_ok_t *amqp_channel_open(amqp_connection_state_t state,
amqp_channel_t channel)
{
- amqp_rpc_reply =
+ state->most_recent_api_result =
AMQP_SIMPLE_RPC(state, channel, CHANNEL, OPEN, OPEN_OK,
amqp_channel_open_t,
AMQP_EMPTY_BYTES);
@@ -118,7 +116,7 @@ amqp_exchange_declare_ok_t *amqp_exchange_declare(amqp_connection_state_t state,
amqp_boolean_t auto_delete,
amqp_table_t arguments)
{
- amqp_rpc_reply =
+ state->most_recent_api_result =
AMQP_SIMPLE_RPC(state, channel, EXCHANGE, DECLARE, DECLARE_OK,
amqp_exchange_declare_t,
0, exchange, type, passive, durable, auto_delete, 0, 0, arguments);
@@ -134,7 +132,7 @@ amqp_queue_declare_ok_t *amqp_queue_declare(amqp_connection_state_t state,
amqp_boolean_t auto_delete,
amqp_table_t arguments)
{
- amqp_rpc_reply =
+ state->most_recent_api_result =
AMQP_SIMPLE_RPC(state, channel, QUEUE, DECLARE, DECLARE_OK,
amqp_queue_declare_t,
0, queue, passive, durable, exclusive, auto_delete, 0, arguments);
@@ -148,7 +146,7 @@ amqp_queue_bind_ok_t *amqp_queue_bind(amqp_connection_state_t state,
amqp_bytes_t routing_key,
amqp_table_t arguments)
{
- amqp_rpc_reply =
+ state->most_recent_api_result =
AMQP_SIMPLE_RPC(state, channel, QUEUE, BIND, BIND_OK,
amqp_queue_bind_t,
0, queue, exchange, routing_key, 0, arguments);
@@ -162,7 +160,7 @@ amqp_queue_unbind_ok_t *amqp_queue_unbind(amqp_connection_state_t state,
amqp_bytes_t binding_key,
amqp_table_t arguments)
{
- amqp_rpc_reply =
+ state->most_recent_api_result =
AMQP_SIMPLE_RPC(state, channel, QUEUE, UNBIND, UNBIND_OK,
amqp_queue_unbind_t,
0, queue, exchange, binding_key, arguments);
@@ -177,7 +175,7 @@ amqp_basic_consume_ok_t *amqp_basic_consume(amqp_connection_state_t state,
amqp_boolean_t no_ack,
amqp_boolean_t exclusive)
{
- amqp_rpc_reply =
+ state->most_recent_api_result =
AMQP_SIMPLE_RPC(state, channel, BASIC, CONSUME, CONSUME_OK,
amqp_basic_consume_t,
0, queue, consumer_tag, no_local, no_ack, exclusive, 0);
@@ -203,8 +201,9 @@ amqp_queue_purge_ok_t *amqp_queue_purge(amqp_connection_state_t state,
amqp_bytes_t queue,
amqp_boolean_t no_wait)
{
- amqp_rpc_reply = AMQP_SIMPLE_RPC(state, channel, QUEUE, PURGE, PURGE_OK,
- amqp_queue_purge_t, channel, queue, no_wait);
+ state->most_recent_api_result =
+ AMQP_SIMPLE_RPC(state, channel, QUEUE, PURGE, PURGE_OK,
+ amqp_queue_purge_t, channel, queue, no_wait);
return RPC_REPLY(amqp_queue_purge_ok_t);
}
@@ -216,17 +215,14 @@ amqp_rpc_reply_t amqp_basic_get(amqp_connection_state_t state,
amqp_method_number_t replies[] = { AMQP_BASIC_GET_OK_METHOD,
AMQP_BASIC_GET_EMPTY_METHOD,
0 };
- amqp_rpc_reply =
+ state->most_recent_api_result =
AMQP_MULTIPLE_RESPONSE_RPC(state, channel, BASIC, GET, replies,
amqp_basic_get_t,
channel, queue, no_ack);
- return amqp_rpc_reply;
+ return state->most_recent_api_result;
}
-/*
- * Expose amqp_rpc_reply to dynamically linked libraries
- */
-amqp_rpc_reply_t amqp_get_rpc_reply(void)
+amqp_rpc_reply_t amqp_get_rpc_reply(amqp_connection_state_t state)
{
- return amqp_rpc_reply;
+ return state->most_recent_api_result;
}