mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Prevent SQLite storage backend from serving expired entries
The SQLite storage backend implements expiration by hand and garbage collection is done in `DoExpire`. This previously relied exclusively on gets not running within `Storage::expire_interval` of the put, otherwise we would potentially serve expired entries. With this patch we explictly check that entries are not expired before serving them so that the SQLite backend should never serve expired entries.
This commit is contained in:
parent
abac0b577c
commit
2f67539c0f
3 changed files with 62 additions and 1 deletions
|
@ -190,7 +190,10 @@ OperationResult SQLite::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
|||
"DO UPDATE SET value_str=?, expire_time=?",
|
||||
table_name.c_str()),
|
||||
db),
|
||||
std::make_pair(util::fmt("select value_str from %s where key_str=?", table_name.c_str()), db),
|
||||
std::make_pair(util::fmt("select value_str, expire_time from %s where key_str=? and "
|
||||
"(expire_time > ? OR expire_time == 0.0)",
|
||||
table_name.c_str()),
|
||||
db),
|
||||
std::make_pair(util::fmt("delete from %s where key_str=?", table_name.c_str()), db),
|
||||
|
||||
std::make_pair(
|
||||
|
@ -348,6 +351,11 @@ OperationResult SQLite::DoGet(ResultCallback* cb, ValPtr key) {
|
|||
return res;
|
||||
}
|
||||
|
||||
if ( auto res = CheckError(sqlite3_bind_double(stmt.get(), 2, run_state::network_time));
|
||||
res.code != ReturnCode::SUCCESS ) {
|
||||
return res;
|
||||
}
|
||||
|
||||
return Step(stmt.get(), true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue