mirror of https://github.com/nymea/nymea.git
Make sure the ping timer exists to prevent crash if not available
parent
f3760ff84a
commit
1d04da6205
|
|
@ -49,6 +49,13 @@ NYMEA_LOGGING_CATEGORY(dcPingTraffic, "PingTraffic")
|
|||
|
||||
Ping::Ping(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_queueTimer = new QTimer(this);
|
||||
m_queueTimer->setInterval(20);
|
||||
m_queueTimer->setSingleShot(true);
|
||||
connect(m_queueTimer, &QTimer::timeout, this, [=](){
|
||||
sendNextReply();
|
||||
});
|
||||
|
||||
// Build socket descriptor
|
||||
m_socketDescriptor = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
|
||||
if (m_socketDescriptor < 0) {
|
||||
|
|
@ -78,13 +85,6 @@ Ping::Ping(QObject *parent) : QObject(parent)
|
|||
m_socketNotifier = new QSocketNotifier(m_socketDescriptor, QSocketNotifier::Read, this);
|
||||
connect(m_socketNotifier, &QSocketNotifier::activated, this, &Ping::onSocketReadyRead);
|
||||
|
||||
m_queueTimer = new QTimer(this);
|
||||
m_queueTimer->setInterval(20);
|
||||
m_queueTimer->setSingleShot(true);
|
||||
connect(m_queueTimer, &QTimer::timeout, this, [=](){
|
||||
sendNextReply();
|
||||
});
|
||||
|
||||
m_socketNotifier->setEnabled(true);
|
||||
m_available = true;
|
||||
qCDebug(dcPing()) << "ICMP socket set up successfully (Socket ID:" << m_socketDescriptor << ")";
|
||||
|
|
|
|||
Loading…
Reference in New Issue