From 5d5b4d719178c48c3e5f616b5eb61b7d68dc2b49 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Sat, 3 Nov 2012 19:39:33 -0700 Subject: [PATCH] nodestack: limit the number of future values per read Not tested very thoroughly, but it seems to limit the future values set as intended. --- nodestack.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nodestack.cc b/nodestack.cc index 743cb86..f73d4cf 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -192,8 +192,13 @@ bool Node::misc_empty() { /** - * Adds a value from a weakly ordered future write to backtrack to. + * Adds a value from a weakly ordered future write to backtrack to. This + * operation may "fail" if the future value is already set (with a later + * expiration), or if the futurevalues set has reached its maximum. + * @see model_params.maxfuturevalues + * * @param value is the value to backtrack to. + * @return True if the future value was successully added; false otherwise */ bool Node::add_future_value(uint64_t value, modelclock_t expiration) { int suitableindex=-1; @@ -211,7 +216,12 @@ bool Node::add_future_value(uint64_t value, modelclock_t expiration) { future_values[suitableindex].expiration=expiration; return true; } - struct future_value newfv={value, expiration}; + + if (model->params.maxfuturevalues > 0 && + (int)future_values.size() >= model->params.maxfuturevalues) + return false; + + struct future_value newfv = {value, expiration}; future_values.push_back(newfv); return true; } -- 2.34.1