Fixed table expiration evaluation.

The expiration attribute expression is now evaluated for every use. Thus
later adjustments of the value (e.g. by redefining a const) will now
take effect. Values less than 0 will disable expiration.
This commit is contained in:
Jan Grashoefer 2016-06-13 21:01:46 +02:00
parent f662989c09
commit 8a87055fcc
4 changed files with 98 additions and 31 deletions

View file

@ -862,6 +862,11 @@ protected:
// Calculates default value for index. Returns 0 if none.
Val* Default(Val* index);
// Returns true if item expiration is defined.
bool ExpirationEnabled() { return expire_time != 0; }
// Returns the expiration time defined by create, read
// or write expire attribute or -1 for invalid values.
double GetExpireTime();
// Calls &expire_func and returns its return interval;
// takes ownership of the reference.
double CallExpireFunc(Val *idx);
@ -874,8 +879,8 @@ protected:
TableType* table_type;
CompositeHash* table_hash;
Attributes* attrs;
double expire_time;
Expr* expire_expr;
Expr* expire_time;
Expr* expire_func;
TableValTimer* timer;
IterCookie* expire_cookie;
PrefixTable* subnets;