summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2012-03-04 14:56:37 -0500
committerAlan Antonuk <alan.antonuk@gmail.com>2012-03-04 14:56:37 -0500
commit9d6551c9e784ccd7f891c338e907c2b7d47502ee (patch)
treea67f53df478eccc3b4d3b6e16f0ff93dc2754bf1
parent54217973952cd582647457c9145423c4e9aa753e (diff)
downloadrabbitmq-c-github-ask-channel_owns_memory_pool.tar.gz
Fix bad assumption about strings being copied to decoding poolchannel_owns_memory_pool
AMQP strings decoded from a frame pool are not copied to the decoding pool - instead they're left in place - so any frame pool used for a method must be associated with a channel and recycled when the frame is no longer in use
-rw-r--r--librabbitmq/amqp_connection.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
index 037d277..a12c52c 100644
--- a/librabbitmq/amqp_connection.c
+++ b/librabbitmq/amqp_connection.c
@@ -197,12 +197,6 @@ int amqp_handle_input(amqp_connection_state_t state,
if (state->frame_pool == NULL) {
return -ERROR_NO_MEMORY;
}
- /* We can recycle here because:
- - Methods data is copied to the decoding_pool
- - Property data is copied to the decoding_pool
- - Body data, the pool is moved to the decoding_pools structure
- */
- recycle_amqp_pool(frame_pool);
state->inbound_buffer.bytes = amqp_pool_alloc(frame_pool,
state->inbound_buffer.len);
if (state->inbound_buffer.bytes == NULL)
@@ -286,7 +280,10 @@ int amqp_handle_input(amqp_connection_state_t state,
decoding_pool, encoded,
&decoded_frame->payload.method.decoded);
if (res < 0)
- return res;
+ return res;
+ /* Move ownership of the pool to the channel hashmap */
+ if (0 != amqp_move_frame_pool(state, decoded_frame->channel))
+ return -ERROR_NO_MEMORY;
break;
@@ -310,6 +307,10 @@ int amqp_handle_input(amqp_connection_state_t state,
if (res < 0)
return res;
+ /* Move ownership of the pool to the channel hashmap */
+ if (0 != amqp_move_frame_pool(state, decoded_frame->channel))
+ return -ERROR_NO_MEMORY;
+
break;
case AMQP_FRAME_BODY: