Skip to content

Commit

Permalink
Improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Marturana committed Jan 13, 2017
1 parent 0549064 commit c20c693
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
6 changes: 3 additions & 3 deletions userspace/libscap/scap.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ scap_t* scap_open_offline_int(const char* fname,
//
// Preliminary initializations
//
handle->m_mode = SCAP_MODE_FILE;
handle->m_mode = SCAP_MODE_CAPTURE;
handle->m_proc_callback = proc_callback;
handle->m_proc_callback_context = proc_callback_context;
handle->m_devs = NULL;
Expand Down Expand Up @@ -487,7 +487,7 @@ scap_t* scap_open(scap_open_args args, char *error)
{
switch(args.mode)
{
case SCAP_MODE_FILE:
case SCAP_MODE_CAPTURE:
return scap_open_offline_int(args.fname, error,
args.proc_callback, args.proc_callback_context,
args.import_users, args.start_offset);
Expand Down Expand Up @@ -859,7 +859,7 @@ int32_t scap_next(scap_t* handle, OUT scap_evt** pevent, OUT uint16_t* pcpuid)

switch(handle->m_mode)
{
case SCAP_MODE_FILE:
case SCAP_MODE_CAPTURE:
res = scap_next_offline(handle, pevent, pcpuid);
break;
case SCAP_MODE_LIVE:
Expand Down
2 changes: 1 addition & 1 deletion userspace/libscap/scap.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ typedef void (*proc_entry_callback)(void* context,
\brief Arguments for scap_open
*/
typedef enum {
SCAP_MODE_FILE,
SCAP_MODE_CAPTURE,
SCAP_MODE_LIVE,
SCAP_MODE_NODRIVER
} scap_mode_t;
Expand Down
14 changes: 7 additions & 7 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void sinsp::init()
// importing the thread table, so that thread table filtering will work with
// container filters
//
if(is_offline())
if(is_capture())
{
uint64_t off = scap_ftell(m_h);
scap_evt* pevent;
Expand Down Expand Up @@ -335,7 +335,7 @@ void sinsp::init()
}
}

if(is_offline() || m_filter_proc_table_when_saving == true)
if(is_capture() || m_filter_proc_table_when_saving == true)
{
import_thread_table();
}
Expand Down Expand Up @@ -542,9 +542,9 @@ void sinsp::open(string filename)
//
// Start the capture
//
m_mode = SCAP_MODE_FILE;
m_mode = SCAP_MODE_CAPTURE;
scap_open_args oargs;
oargs.mode = SCAP_MODE_FILE;
oargs.mode = SCAP_MODE_CAPTURE;
oargs.fname = filename.c_str();
oargs.proc_callback = NULL;
oargs.proc_callback_context = NULL;
Expand Down Expand Up @@ -685,7 +685,7 @@ void sinsp::on_new_entry_from_proc(void* context,
{
sinsp_threadinfo newti(this);
newti.init(tinfo);
if(m_mode == SCAP_MODE_NODRIVER)
if(is_nodriver())
{
auto sinsp_tinfo = find_thread(tid, true);
if(sinsp_tinfo == nullptr || newti.m_clone_ts > sinsp_tinfo->m_clone_ts)
Expand Down Expand Up @@ -789,7 +789,7 @@ void sinsp::import_ipv4_interface(const sinsp_ipv4_ifinfo& ifinfo)
void sinsp::refresh_ifaddr_list()
{
#ifdef HAS_CAPTURE
if(!is_offline())
if(!is_capture())
{
ASSERT(m_network_interfaces);
scap_refresh_iflist(m_h);
Expand Down Expand Up @@ -1027,7 +1027,7 @@ int32_t sinsp::next(OUT sinsp_evt **puevt)
//
// Run the periodic connection and thread table cleanup
//
if(!is_offline())
if(!is_capture())
{
m_thread_manager->remove_inactive_threads();
m_container_manager.remove_inactive_containers();
Expand Down
12 changes: 10 additions & 2 deletions userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ class SINSP_PUBLIC sinsp
/*!
\brief Returns true if the current capture is offline
*/
inline bool is_offline()
inline bool is_capture()
{
return m_mode == SCAP_MODE_FILE;
return m_mode == SCAP_MODE_CAPTURE;
}

/*!
Expand All @@ -590,6 +590,14 @@ class SINSP_PUBLIC sinsp
return m_mode == SCAP_MODE_LIVE;
}

/*!
\brief Returns true if the current capture is live
*/
inline bool is_nodriver()
{
return m_mode == SCAP_MODE_NODRIVER;
}

/*!
\brief Set the debugging mode of the inspector.
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/threadinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void sinsp_threadinfo::init(scap_threadinfo* pi)
set_cgroups(pi->cgroups, pi->cgroups_len);
m_root = pi->root;
ASSERT(m_inspector);
m_inspector->m_container_manager.resolve_container(this, !m_inspector->is_offline());
m_inspector->m_container_manager.resolve_container(this, !m_inspector->is_capture());
//
// Prepare for filtering
//
Expand Down

0 comments on commit c20c693

Please sign in to comment.