Skip to content

Commit

Permalink
fix(userspace/libsinsp): make sure simple sinsp wrapper methods are i…
Browse files Browse the repository at this point in the history
…nlined

Signed-off-by: Jason Dellaluce <[email protected]>
  • Loading branch information
jasondellaluce authored and poiana committed May 3, 2024
1 parent e285a47 commit bf1835b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 41 deletions.
35 changes: 0 additions & 35 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,21 +1398,6 @@ uint64_t sinsp::get_num_events() const
}
}

threadinfo_map_t::ptr_t sinsp::get_thread_ref(int64_t tid, bool query_os_if_not_found, bool lookup_only, bool main_thread)
{
return m_thread_manager->get_thread_ref(tid, query_os_if_not_found, lookup_only, main_thread);
}

std::shared_ptr<sinsp_threadinfo> sinsp::add_thread(std::unique_ptr<sinsp_threadinfo> ptinfo)
{
return m_thread_manager->add_thread(std::move(ptinfo), false);
}

void sinsp::remove_thread(int64_t tid)
{
m_thread_manager->remove_thread(tid);
}

bool sinsp::suppress_events_comm(const std::string &comm)
{
m_suppress.suppress_comm(comm);
Expand Down Expand Up @@ -1752,16 +1737,6 @@ const scap_agent_info* sinsp::get_agent_info() const
return m_agent_info;
}

std::shared_ptr<sinsp_stats_v2> sinsp::get_sinsp_stats_v2()
{
return m_sinsp_stats_v2;
}

std::shared_ptr<const sinsp_stats_v2> sinsp::get_sinsp_stats_v2() const
{
return m_sinsp_stats_v2;
}

std::unique_ptr<sinsp_filter_check> sinsp::new_generic_filtercheck()
{
return std::make_unique<sinsp_filter_check_gen_event>();
Expand Down Expand Up @@ -2209,13 +2184,3 @@ void sinsp::set_track_connection_status(bool enabled)
m_parser->set_track_connection_status(enabled);
}

uint64_t sinsp::get_new_ts() const
{
// m_lastevent_ts = 0 at startup when containers are
// being created as a part of the initial process
// scan.
return (m_lastevent_ts == 0)
? sinsp_utils::get_current_time_ns()
: m_lastevent_ts;
}

36 changes: 30 additions & 6 deletions userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,15 @@ class SINSP_PUBLIC sinsp : public capture_stats_source
\brief Return sinsp stats v2 containing continually updated counters around thread and fd state tables.
*/
std::shared_ptr<sinsp_stats_v2> get_sinsp_stats_v2();
std::shared_ptr<const sinsp_stats_v2> get_sinsp_stats_v2() const;
inline std::shared_ptr<sinsp_stats_v2> get_sinsp_stats_v2()
{
return m_sinsp_stats_v2;
}

inline std::shared_ptr<const sinsp_stats_v2> get_sinsp_stats_v2() const
{
return m_sinsp_stats_v2;
}

/*!
\brief Look up a thread given its tid and return its information,
Expand All @@ -496,7 +503,10 @@ class SINSP_PUBLIC sinsp : public capture_stats_source
@throws a sinsp_exception containing the error string is thrown in case
of failure.
*/
threadinfo_map_t::ptr_t get_thread_ref(int64_t tid, bool query_os_if_not_found = false, bool lookup_only = true, bool main_thread = false);
inline threadinfo_map_t::ptr_t get_thread_ref(int64_t tid, bool query_os_if_not_found = false, bool lookup_only = true, bool main_thread = false)
{
return m_thread_manager->get_thread_ref(tid, query_os_if_not_found, lookup_only, main_thread);
}

/*!
\brief Fill the given structure with statistics about the currently
Expand Down Expand Up @@ -1003,18 +1013,32 @@ class SINSP_PUBLIC sinsp : public capture_stats_source
* \return The current time in nanoseconds if the last event timestamp is 0,
* otherwise, the last event timestamp.
*/
uint64_t get_new_ts() const;
inline uint64_t get_new_ts() const
{
// m_lastevent_ts = 0 at startup when containers are
// being created as a part of the initial process
// scan.
return (m_lastevent_ts == 0)
? sinsp_utils::get_current_time_ns()
: m_lastevent_ts;
}

bool remove_inactive_threads();

std::shared_ptr<sinsp_threadinfo> add_thread(std::unique_ptr<sinsp_threadinfo> ptinfo);
inline std::shared_ptr<sinsp_threadinfo> add_thread(std::unique_ptr<sinsp_threadinfo> ptinfo)
{
return m_thread_manager->add_thread(std::move(ptinfo), false);
}

void set_mode(sinsp_mode_t value)
{
m_mode = value;
}

void remove_thread(int64_t tid);
inline void remove_thread(int64_t tid)
{
m_thread_manager->remove_thread(tid);
}

inline const struct scap_platform* get_scap_platform() const
{
Expand Down

0 comments on commit bf1835b

Please sign in to comment.