mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-12 03:22:41 +00:00
fix: solve runtime issues with emscripten build
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com> Co-authored-by: Rohith Raju <rohithraju488@gmail.com>
This commit is contained in:
parent
0faa45669b
commit
ce6368a89e
@ -167,6 +167,7 @@ target_include_directories(falco PUBLIC ${FALCO_INCLUDE_DIRECTORIES})
|
|||||||
|
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
target_compile_options(falco PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
|
target_compile_options(falco PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
|
||||||
|
target_link_options(falco PRIVATE "-sALLOW_MEMORY_GROWTH=1")
|
||||||
target_link_options(falco PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
|
target_link_options(falco PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
|
||||||
target_link_options(falco PRIVATE "-sEXPORTED_FUNCTIONS=['_main','_htons','_ntohs']")
|
target_link_options(falco PRIVATE "-sEXPORTED_FUNCTIONS=['_main','_htons','_ntohs']")
|
||||||
endif()
|
endif()
|
||||||
|
@ -25,7 +25,7 @@ falco::app::run_result falco::app::actions::load_plugins(falco::app::state& s)
|
|||||||
#if !defined(MUSL_OPTIMIZED) and !defined(__EMSCRIPTEN__)
|
#if !defined(MUSL_OPTIMIZED) and !defined(__EMSCRIPTEN__)
|
||||||
if (!s.config->m_plugins.empty())
|
if (!s.config->m_plugins.empty())
|
||||||
{
|
{
|
||||||
return run_result::fatal("Loading plugins dynamic libraries is not supported with this Falco build");
|
return run_result::fatal("Loading plugins dynamic libraries is not supported by this Falco build");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Initialize the set of loaded event sources.
|
// Initialize the set of loaded event sources.
|
||||||
|
@ -493,6 +493,13 @@ falco::app::run_result falco::app::actions::process_events(falco::app::state& s)
|
|||||||
{
|
{
|
||||||
print_enabled_event_sources(s);
|
print_enabled_event_sources(s);
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
if(s.enabled_sources.size() > 1)
|
||||||
|
{
|
||||||
|
return run_result::fatal("enabling multiple event sources is not supported by this Falco build");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// start event processing for all enabled sources
|
// start event processing for all enabled sources
|
||||||
falco::semaphore termination_sem(s.enabled_sources.size());
|
falco::semaphore termination_sem(s.enabled_sources.size());
|
||||||
std::vector<live_context> ctxs;
|
std::vector<live_context> ctxs;
|
||||||
|
@ -64,13 +64,16 @@ falco_outputs::falco_outputs(
|
|||||||
{
|
{
|
||||||
add_output(output);
|
add_output(output);
|
||||||
}
|
}
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
m_worker_thread = std::thread(&falco_outputs::worker, this);
|
m_worker_thread = std::thread(&falco_outputs::worker, this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
falco_outputs::~falco_outputs()
|
falco_outputs::~falco_outputs()
|
||||||
{
|
{
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
this->stop_worker();
|
this->stop_worker();
|
||||||
|
#endif
|
||||||
for(auto o : m_outputs)
|
for(auto o : m_outputs)
|
||||||
{
|
{
|
||||||
delete o;
|
delete o;
|
||||||
@ -274,6 +277,11 @@ inline void falco_outputs::push(const ctrl_msg& cmsg)
|
|||||||
fprintf(stderr, "Fatal error: Output queue reached maximum capacity. Exiting.\n");
|
fprintf(stderr, "Fatal error: Output queue reached maximum capacity. Exiting.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
for (auto o : m_outputs)
|
||||||
|
{
|
||||||
|
process_msg(o, cmsg);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,11 +305,24 @@ void falco_outputs::worker() noexcept
|
|||||||
m_queue.pop(cmsg);
|
m_queue.pop(cmsg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(const auto o : m_outputs)
|
for(auto o : m_outputs)
|
||||||
{
|
{
|
||||||
wd.set_timeout(timeout, o->get_name());
|
wd.set_timeout(timeout, o->get_name());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
process_msg(o, cmsg);
|
||||||
|
}
|
||||||
|
catch(const std::exception &e)
|
||||||
|
{
|
||||||
|
falco_logger::log(LOG_ERR, o->get_name() + ": " + std::string(e.what()) + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wd.cancel_timeout();
|
||||||
|
} while(cmsg.type != ctrl_msg_type::CTRL_MSG_STOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void falco_outputs::process_msg(falco::outputs::abstract_output* o, const ctrl_msg& cmsg)
|
||||||
|
{
|
||||||
switch(cmsg.type)
|
switch(cmsg.type)
|
||||||
{
|
{
|
||||||
case ctrl_msg_type::CTRL_MSG_OUTPUT:
|
case ctrl_msg_type::CTRL_MSG_OUTPUT:
|
||||||
@ -317,12 +338,4 @@ void falco_outputs::worker() noexcept
|
|||||||
default:
|
default:
|
||||||
falco_logger::log(LOG_DEBUG, "Outputs worker received an unknown message type\n");
|
falco_logger::log(LOG_DEBUG, "Outputs worker received an unknown message type\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(const std::exception &e)
|
|
||||||
{
|
|
||||||
falco_logger::log(LOG_ERR, o->get_name() + ": " + std::string(e.what()) + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wd.cancel_timeout();
|
|
||||||
} while(cmsg.type != ctrl_msg_type::CTRL_MSG_STOP);
|
|
||||||
}
|
}
|
||||||
|
@ -118,4 +118,5 @@ private:
|
|||||||
void worker() noexcept;
|
void worker() noexcept;
|
||||||
void stop_worker();
|
void stop_worker();
|
||||||
void add_output(falco::outputs::config oc);
|
void add_output(falco::outputs::config oc);
|
||||||
|
inline void process_msg(falco::outputs::abstract_output* o, const ctrl_msg& cmsg);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user