Skip to content

Commit 314b63a

Browse files
committed
make the code compile again when HAS_CAPTURE is disabled
1 parent fcecde6 commit 314b63a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

userspace/libsinsp/docker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#if defined(__linux__)
66

7-
#include "docker.h"
87
#include "sinsp.h"
98
#include "sinsp_int.h"
9+
#include "docker.h"
1010
#include "user_event.h"
1111

1212
const std::string docker::DOCKER_SOCKET_FILE = "/var/run/docker.sock";
@@ -227,6 +227,7 @@ void docker::set_event_json(json_ptr_t json, const std::string&)
227227
}
228228
}
229229

230+
#ifdef HAS_CAPTURE
230231
void docker::handle_event(Json::Value&& root)
231232
{
232233
if(m_event_filter && (m_event_counter < sinsp_user_event::max_events_per_cycle()))
@@ -470,5 +471,6 @@ std::string docker::get_socket_file()
470471
sock_file.append(DOCKER_SOCKET_FILE);
471472
return sock_file;
472473
}
474+
#endif // HAS_CAPTURE
473475

474476
#endif // __linux__

userspace/libsinsp/docker.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ class docker
5050
static std::string get_socket_file();
5151

5252
private:
53-
static const std::string DOCKER_SOCKET_FILE;
5453
void connect();
5554
void send_event_data_request();
5655
void check_collector_status();
5756

58-
void handle_event(Json::Value&& root);
59-
6057
template <typename T>
6158
bool connect(T http, typename T::element_type::json_callback_func_t func, int expected_connections)
6259
{
@@ -89,21 +86,23 @@ class docker
8986
typedef handler_t::ptr_t handler_ptr_t;
9087
typedef socket_collector<handler_t> collector_t;
9188

92-
std::string m_id;
9389
handler_ptr_t m_event_http;
9490
collector_t m_collector;
9591
std::string m_event_uri;
9692
#endif // HAS_CAPTURE
9793

9894
private:
9995

96+
static const std::string DOCKER_SOCKET_FILE;
10097
typedef std::vector<json_ptr_t> event_list_t;
10198
typedef sinsp_logger::event_severity severity_t;
10299
typedef std::unordered_map<std::string, severity_t> severity_map_t;
103100
typedef std::unordered_map<std::string, std::string> name_translation_map_t;
104101
typedef std::set<std::string> entity_events_t;
105102
const std::string& translate_name(const std::string& event_name);
103+
void handle_event(Json::Value&& root);
106104

105+
std::string m_id;
107106
long m_timeout_ms;
108107
bool m_is_captured;
109108
bool m_verbose;
@@ -120,6 +119,7 @@ class docker
120119
bool m_event_limit_exceeded = false;
121120
};
122121

122+
#ifdef HAS_CAPTURE
123123
inline const std::string& docker::get_id() const
124124
{
125125
return m_id;
@@ -139,6 +139,7 @@ inline const std::string& docker::get_machine_id() const
139139
{
140140
return m_machine_id;
141141
}
142+
#endif // HAS_CAPTURE
142143

143144
inline const std::string& docker::translate_name(const std::string& event_name)
144145
{
@@ -150,6 +151,7 @@ inline const std::string& docker::translate_name(const std::string& event_name)
150151
return event_name;
151152
}
152153

154+
#ifdef HAS_CAPTURE
153155
inline bool docker::is_container_event(const std::string& evt_name)
154156
{
155157
return m_container_events.find(evt_name) != m_container_events.end();
@@ -169,6 +171,7 @@ inline bool docker::is_network_event(const std::string& evt_name)
169171
{
170172
return m_network_events.find(evt_name) != m_network_events.end();
171173
}
174+
#endif // HAS_CAPTURE
172175

173176
inline void docker::reset_event_counter()
174177
{

0 commit comments

Comments
 (0)