tune timeouts
This commit is contained in:
parent
c5c760f4a7
commit
81b1ce65b9
@ -27,6 +27,10 @@ DeviceMonitor::~DeviceMonitor()
|
|||||||
|
|
||||||
void DeviceMonitor::update()
|
void DeviceMonitor::update()
|
||||||
{
|
{
|
||||||
|
if (m_pingProcess->state() != QProcess::NotRunning) {
|
||||||
|
qCDebug(dcNetworkDetector()) << "Previous ping still running for device" << m_host->address() << ". Not updating.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
lookupArpCache();
|
lookupArpCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,9 +54,14 @@ void DeviceMonitor::ping()
|
|||||||
}
|
}
|
||||||
if (!targetInterface.isValid()) {
|
if (!targetInterface.isValid()) {
|
||||||
qCWarning(dcNetworkDetector()) << "Could not find a suitable interface to ping for" << m_host->address();
|
qCWarning(dcNetworkDetector()) << "Could not find a suitable interface to ping for" << m_host->address();
|
||||||
|
if (m_host->reachable()) {
|
||||||
|
m_host->setReachable(false);
|
||||||
|
emit reachableChanged(false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_pingProcess->start("arping", {"-I", targetInterface.name(), "-f", "-w", "5", m_host->address()});
|
|
||||||
|
m_pingProcess->start("arping", {"-I", targetInterface.name(), "-f", "-w", "90", m_host->address()});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceMonitor::arpLookupFinished(int exitCode)
|
void DeviceMonitor::arpLookupFinished(int exitCode)
|
||||||
@ -95,12 +104,6 @@ void DeviceMonitor::arpLookupFinished(int exitCode)
|
|||||||
qCDebug(dcNetworkDetector()) << "Device" << m_host->macAddress() << "not found in ARP cache. Trying to ping it on" << m_host->address();
|
qCDebug(dcNetworkDetector()) << "Device" << m_host->macAddress() << "not found in ARP cache. Trying to ping it on" << m_host->address();
|
||||||
ping();
|
ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_host->reachable() && m_host->lastSeenTime().addSecs(20) < QDateTime::currentDateTime()) {
|
|
||||||
qCDebug(dcNetworkDetector()) << "Could not reach device for 20 seconds. Marking it as gone." << m_host->address() << m_host->macAddress();
|
|
||||||
m_host->setReachable(false);
|
|
||||||
emit reachableChanged(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceMonitor::pingFinished(int exitCode)
|
void DeviceMonitor::pingFinished(int exitCode)
|
||||||
@ -116,6 +119,10 @@ void DeviceMonitor::pingFinished(int exitCode)
|
|||||||
emit seen();
|
emit seen();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(dcNetworkDetector()) << "Could not ping device" << m_host->macAddress() << m_host->address();
|
qCDebug(dcNetworkDetector()) << "Could not ping device" << m_host->macAddress() << m_host->address();
|
||||||
|
if (m_host->reachable()) {
|
||||||
|
m_host->setReachable(false);
|
||||||
|
emit reachableChanged(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// read data to discard it from socket
|
// read data to discard it from socket
|
||||||
QString data = QString::fromLatin1(m_pingProcess->readAll());
|
QString data = QString::fromLatin1(m_pingProcess->readAll());
|
||||||
|
|||||||
@ -82,6 +82,7 @@ DeviceManager::DeviceSetupStatus DevicePluginNetworkDetector::setupDevice(Device
|
|||||||
connect(monitor, &DeviceMonitor::addressChanged, this, &DevicePluginNetworkDetector::deviceAddressChanged);
|
connect(monitor, &DeviceMonitor::addressChanged, this, &DevicePluginNetworkDetector::deviceAddressChanged);
|
||||||
connect(monitor, &DeviceMonitor::seen, this, &DevicePluginNetworkDetector::deviceSeen);
|
connect(monitor, &DeviceMonitor::seen, this, &DevicePluginNetworkDetector::deviceSeen);
|
||||||
m_monitors.insert(monitor, device);
|
m_monitors.insert(monitor, device);
|
||||||
|
monitor->update();
|
||||||
|
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return DeviceManager::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,8 +43,7 @@
|
|||||||
"displayName": "Device is present",
|
"displayName": "Device is present",
|
||||||
"displayNameEvent": "Device is present changed",
|
"displayNameEvent": "Device is present changed",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false,
|
"defaultValue": false
|
||||||
"cached": false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "b51d54c9-cce1-43f0-a35d-52fc2d8d302c",
|
"id": "b51d54c9-cce1-43f0-a35d-52fc2d8d302c",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user