mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-11 19:12:12 +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)
|
||||
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 "-sEXPORTED_FUNCTIONS=['_main','_htons','_ntohs']")
|
||||
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 (!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
|
||||
// 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);
|
||||
|
||||
#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
|
||||
falco::semaphore termination_sem(s.enabled_sources.size());
|
||||
std::vector<live_context> ctxs;
|
||||
|
@ -64,13 +64,16 @@ falco_outputs::falco_outputs(
|
||||
{
|
||||
add_output(output);
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
m_worker_thread = std::thread(&falco_outputs::worker, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
falco_outputs::~falco_outputs()
|
||||
{
|
||||
#ifndef __EMSCRIPTEN__
|
||||
this->stop_worker();
|
||||
#endif
|
||||
for(auto o : m_outputs)
|
||||
{
|
||||
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");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#else
|
||||
for (auto o : m_outputs)
|
||||
{
|
||||
process_msg(o, cmsg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -297,26 +305,12 @@ void falco_outputs::worker() noexcept
|
||||
m_queue.pop(cmsg);
|
||||
#endif
|
||||
|
||||
for(const auto o : m_outputs)
|
||||
for(auto o : m_outputs)
|
||||
{
|
||||
wd.set_timeout(timeout, o->get_name());
|
||||
try
|
||||
{
|
||||
switch(cmsg.type)
|
||||
{
|
||||
case ctrl_msg_type::CTRL_MSG_OUTPUT:
|
||||
o->output(&cmsg);
|
||||
break;
|
||||
case ctrl_msg_type::CTRL_MSG_CLEANUP:
|
||||
case ctrl_msg_type::CTRL_MSG_STOP:
|
||||
o->cleanup();
|
||||
break;
|
||||
case ctrl_msg_type::CTRL_MSG_REOPEN:
|
||||
o->reopen();
|
||||
break;
|
||||
default:
|
||||
falco_logger::log(LOG_DEBUG, "Outputs worker received an unknown message type\n");
|
||||
}
|
||||
process_msg(o, cmsg);
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
@ -326,3 +320,22 @@ void falco_outputs::worker() noexcept
|
||||
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)
|
||||
{
|
||||
case ctrl_msg_type::CTRL_MSG_OUTPUT:
|
||||
o->output(&cmsg);
|
||||
break;
|
||||
case ctrl_msg_type::CTRL_MSG_CLEANUP:
|
||||
case ctrl_msg_type::CTRL_MSG_STOP:
|
||||
o->cleanup();
|
||||
break;
|
||||
case ctrl_msg_type::CTRL_MSG_REOPEN:
|
||||
o->reopen();
|
||||
break;
|
||||
default:
|
||||
falco_logger::log(LOG_DEBUG, "Outputs worker received an unknown message type\n");
|
||||
}
|
||||
}
|
||||
|
@ -118,4 +118,5 @@ private:
|
||||
void worker() noexcept;
|
||||
void stop_worker();
|
||||
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