summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2013-07-14 13:06:49 -0700
committerJosh Blum2013-07-14 13:06:49 -0700
commit6f9ab7732da5731ee0db59d9623111b7af9b2e94 (patch)
tree72b0a25f5ed1f77be144d011b5c5d7df4f9b0cdf /lib
parentebb794f538612633d8018922eda4e6ac84b6d585 (diff)
downloadsandhi-6f9ab7732da5731ee0db59d9623111b7af9b2e94.tar.gz
sandhi-6f9ab7732da5731ee0db59d9623111b7af9b2e94.tar.bz2
sandhi-6f9ab7732da5731ee0db59d9623111b7af9b2e94.zip
gras: fixed allocation override bug + unit test
When multiple consumers all choose to override the buffer, they were doing so with the same token, this lead to some buffer allocation confusion and nasty errors. Its ok for one to win out, but each allocator needs a unique token. There is also a unit test to check for this behaviour.
Diffstat (limited to 'lib')
-rw-r--r--lib/block_allocator.cpp4
-rw-r--r--lib/input_handlers.cpp9
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp
index 3168bc2..8246037 100644
--- a/lib/block_allocator.cpp
+++ b/lib/block_allocator.cpp
@@ -81,10 +81,6 @@ void BlockActor::handle_top_alloc(const TopAllocMessage &, const Theron::Address
data->output_queues.set_buffer_queue(i, queue);
InputAllocMessage message;
- //new token for the downstream allocator
- //so when the downstream overrides, old token gets reset
- token = SBufferToken(new SBufferDeleter(deleter));
- config.token = token;
message.config = config;
message.token = token;
worker->post_downstream(i, message);
diff --git a/lib/input_handlers.cpp b/lib/input_handlers.cpp
index 3027257..3c985ce 100644
--- a/lib/input_handlers.cpp
+++ b/lib/input_handlers.cpp
@@ -93,9 +93,16 @@ void BlockActor::handle_input_alloc(const InputAllocMessage &message, const Ther
MESSAGE_TRACER();
const size_t index = message.index;
+ //new token for this downstream allocator
+ //so if the downstream overrides, it has a unique token
+ SBufferDeleter deleter = *(message.token);
+ SBufferToken token = SBufferToken(new SBufferDeleter(deleter));
+ SBufferConfig config = message.config;
+ config.token = token;
+
//handle the upstream block allocation request
OutputAllocMessage new_msg;
- new_msg.queue = data->block->input_buffer_allocator(index, message.config);
+ new_msg.queue = data->block->input_buffer_allocator(index, config);
if (new_msg.queue) worker->post_upstream(index, new_msg);
}