Skip to content

Commit

Permalink
Parse only sockets for nodriver mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Marturana committed Jan 18, 2017
1 parent 89298f0 commit df8abb2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion userspace/libscap/scap.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ scap_t* scap_open_nodriver_int(char *error,
handle->m_machine_info.reserved3 = 0;
handle->m_machine_info.reserved4 = 0;
handle->m_driver_procinfo = NULL;
handle->m_fd_lookup_limit = 20; // fd lookup is limited here because is very expensive
handle->m_fd_lookup_limit = SCAP_NODRIVER_MAX_FD_LOOKUP; // fd lookup is limited here because is very expensive

//
// Create the interface list
Expand Down
8 changes: 8 additions & 0 deletions userspace/libscap/scap_fds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,14 @@ int32_t scap_fd_scan_fd_dir(scap_t *handle, char *procdir, scap_threadinfo *tinf
{
continue;
}

// In no driver mode to limit cpu usage we just parse sockets
// because we are interested only on them
if(handle->m_mode == SCAP_MODE_NODRIVER && !S_ISSOCK(sb.st_mode))
{
continue;
}

switch(sb.st_mode & S_IFMT)
{
case S_IFIFO:
Expand Down
2 changes: 2 additions & 0 deletions userspace/libscap/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
#define INCLUDE_UNKNOWN_SOCKET_FDS

#define USE_ZLIB

#define SCAP_NODRIVER_MAX_FD_LOOKUP 20

0 comments on commit df8abb2

Please sign in to comment.