mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/4742-skip-storage-thread'
* origin/topic/timw/4742-skip-storage-thread: Avoid starting up storage expiration thread with zero backends Remove a couple of obsolete TODOs in storage manager
This commit is contained in:
commit
938073dfed
5 changed files with 18 additions and 10 deletions
6
CHANGES
6
CHANGES
|
@ -1,3 +1,9 @@
|
|||
8.1.0-dev.555 | 2025-09-17 08:44:43 -0700
|
||||
|
||||
* Avoid starting up storage expiration thread with zero backends (Tim Wojtulewicz, Corelight)
|
||||
|
||||
* Remove a couple of obsolete TODOs in storage manager (Tim Wojtulewicz, Corelight)
|
||||
|
||||
8.1.0-dev.552 | 2025-09-16 13:31:39 -0700
|
||||
|
||||
* Reword comment about when ZeroMQ is required for the build (Tim Wojtulewicz, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
8.1.0-dev.552
|
||||
8.1.0-dev.555
|
||||
|
|
|
@ -22,7 +22,7 @@ void detail::ExpirationTimer::Dispatch(double t, bool is_expire) {
|
|||
// start another one running. If this causes us to skip a cycle, that's not
|
||||
// a big deal as the next cycle will catch anything that should be expired
|
||||
// in the interim.
|
||||
if ( ! expire_running.test_and_set() ) {
|
||||
if ( ! expire_running.test_and_set() && storage_mgr->BackendCount() > 0 ) {
|
||||
DBG_LOG(DBG_STORAGE, "Starting new expiration thread");
|
||||
storage_mgr->expiration_thread = zeek::jthread([t]() { storage_mgr->Expire(t); });
|
||||
}
|
||||
|
@ -100,8 +100,6 @@ OperationResult Manager::OpenBackend(BackendPtr backend, OpenResultCallback* cb,
|
|||
|
||||
RegisterBackend(std::move(backend));
|
||||
|
||||
// TODO: post Storage::backend_opened event
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -116,11 +114,7 @@ OperationResult Manager::CloseBackend(BackendPtr backend, ResultCallback* cb) {
|
|||
backends.erase(it);
|
||||
}
|
||||
|
||||
auto res = backend->Close(cb);
|
||||
|
||||
// TODO: post Storage::backend_lost event
|
||||
|
||||
return res;
|
||||
return backend->Close(cb);
|
||||
}
|
||||
|
||||
void Manager::Expire(double t) {
|
||||
|
@ -152,4 +146,11 @@ void Manager::RegisterBackend(BackendPtr backend) {
|
|||
DBG_LOG(DBG_STORAGE, "Registered backends: %zu", backends.size());
|
||||
}
|
||||
|
||||
size_t Manager::BackendCount() {
|
||||
// Expiration runs on a separate thread and loops over the vector of backends. The mutex
|
||||
// here ensures exclusive access.
|
||||
std::unique_lock<std::mutex> lk(backends_mtx);
|
||||
return backends.size();
|
||||
}
|
||||
|
||||
} // namespace zeek::storage
|
||||
|
|
|
@ -113,6 +113,7 @@ protected:
|
|||
friend class storage::detail::ExpirationTimer;
|
||||
void RunExpireThread();
|
||||
void StartExpirationTimer();
|
||||
size_t BackendCount();
|
||||
zeek::jthread expiration_thread;
|
||||
|
||||
friend class storage::OpenResultCallback;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# @TEST-PORT: REDIS_PORT
|
||||
|
||||
# @TEST-EXEC: btest-bg-run redis-server run-redis-server ${REDIS_PORT%/tcp}
|
||||
# @TEST-EXEC: zcat <$TRACES/echo-connections.pcap.gz | zeek -B storage -b -r - %INPUT > out
|
||||
# @TEST-EXEC: zeek -B storage -b %INPUT > out
|
||||
# @TEST-EXEC: btest-bg-wait -k 1
|
||||
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue