/* Add it to the list first to present a consistent state in block_reserved
signal. */
blocks.push_back(block);
+
+ bool first_reserve = (cur_blocks_end==blocks.end());
+ if(first_reserve)
+ --cur_blocks_end;
+
try
{
if(!block->reserve(&train))
{
+ if(first_reserve)
+ cur_blocks_end = blocks.end();
blocks.pop_back();
return false;
}
}
catch(...)
{
+ if(first_reserve)
+ cur_blocks_end = blocks.end();
blocks.pop_back();
throw;
}