Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/inputs/netprobe/PingProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ bool PingProbe::start(std::shared_ptr<uvw::Loop> io_loop)
}
});

_recv_connection = PingReceiver::recv_signal.connect([this](pcpp::Packet &packet, timespec stamp) { _recv(packet, TestType::Ping, _name, stamp); });
_recv_connection = PingReceiver::recv_signal.connect([this](pcpp::Packet &packet, timespec stamp) {
std::unique_lock<std::mutex> lock(_mutex);
_recv(packet, TestType::Ping, _name, stamp);
});

(_sequence == UCHAR_MAX) ? _sequence = 0 : _sequence++;
_send_icmp_v4(_internal_sequence);
Expand Down Expand Up @@ -296,6 +299,7 @@ void PingProbe::_send_icmp_v4(uint8_t sequence)
if (rc != SOCKET_ERROR) {
pcpp::Packet packet;
packet.addLayer(&icmp);
std::unique_lock<std::mutex> lock(_mutex);
_send(packet, TestType::Ping, _name, stamp);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/inputs/netprobe/PingProbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class PingProbe final : public NetProbe
sockaddr_in _sa;
sockaddr_in6 _sa6;
sigslot::connection _recv_connection;
std::mutex _mutex;

void _send_icmp_v4(uint8_t sequence);
std::optional<ErrorType> _get_addr();
Expand Down