mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-15 23:36:19 +00:00
cleanup(userspace/falco): always set queue capacity and use largest long as default for unbounded
Co-authored-by: Andrea Terzolo <andreaterzolo3@gmail.com> Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
This commit is contained in:
parent
1e94598eca
commit
a61f24066f
@ -21,7 +21,11 @@ limitations under the License.
|
||||
#include <mutex>
|
||||
#include <sinsp.h>
|
||||
|
||||
#define DEFAULT_OUTPUTS_QUEUE_CAPACITY 0
|
||||
//
|
||||
// equivalent to an "unbounded queue" in TBB terms or largest long value
|
||||
// https://github.com/oneapi-src/oneTBB/blob/b2474bfc636937052d05daf8b3f4d6b76e20273a/include/oneapi/tbb/concurrent_queue.h#L554
|
||||
//
|
||||
#define DEFAULT_OUTPUTS_QUEUE_CAPACITY std::ptrdiff_t(~size_t(0) / 2)
|
||||
|
||||
//
|
||||
// Most falco_* classes can throw exceptions. Unless directly related
|
||||
|
@ -284,6 +284,11 @@ void falco_configuration::load_yaml(const std::string& config_name, const yaml_h
|
||||
|
||||
m_buffered_outputs = config.get_scalar<bool>("buffered_outputs", false);
|
||||
m_outputs_queue_capacity = config.get_scalar<size_t>("outputs_queue.capacity", DEFAULT_OUTPUTS_QUEUE_CAPACITY);
|
||||
// We use 0 in falco.yaml to indicate an unbounded queue; equivalent to the largest long value
|
||||
if (m_outputs_queue_capacity == 0)
|
||||
{
|
||||
m_outputs_queue_capacity = DEFAULT_OUTPUTS_QUEUE_CAPACITY;
|
||||
}
|
||||
std::string recovery = config.get_scalar<std::string>("outputs_queue.recovery", "exit");
|
||||
if (!falco_common::parse_recovery(recovery, m_outputs_queue_recovery))
|
||||
{
|
||||
|
@ -67,10 +67,7 @@ falco_outputs::falco_outputs(
|
||||
}
|
||||
#ifndef __EMSCRIPTEN__
|
||||
m_worker_thread = std::thread(&falco_outputs::worker, this);
|
||||
if (outputs_queue_capacity > 0)
|
||||
{
|
||||
m_queue.set_capacity(outputs_queue_capacity);
|
||||
}
|
||||
m_queue.set_capacity(outputs_queue_capacity);
|
||||
m_recovery = outputs_queue_recovery;
|
||||
m_outputs_queue_num_drops = 0UL;
|
||||
#endif
|
||||
|
@ -91,10 +91,7 @@ stats_writer::stats_writer(
|
||||
m_config = config;
|
||||
// capacity and controls should not be relevant for stats outputs, adopt capacity
|
||||
// for completeness, but do not implement config recovery strategies.
|
||||
if (config->m_outputs_queue_capacity > 0)
|
||||
{
|
||||
m_queue.set_capacity(config->m_outputs_queue_capacity);
|
||||
}
|
||||
m_queue.set_capacity(config->m_outputs_queue_capacity);
|
||||
if (config->m_metrics_enabled)
|
||||
{
|
||||
if (!config->m_metrics_output_file.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user