tune timeouts

master
Michael Zanetti 2018-12-31 01:07:48 +01:00
parent c5c760f4a7
commit 81b1ce65b9
3 changed files with 16 additions and 9 deletions

View File

@ -27,6 +27,10 @@ DeviceMonitor::~DeviceMonitor()
void DeviceMonitor::update()
{
if (m_pingProcess->state() != QProcess::NotRunning) {
qCDebug(dcNetworkDetector()) << "Previous ping still running for device" << m_host->address() << ". Not updating.";
return;
}
lookupArpCache();
}
@ -50,9 +54,14 @@ void DeviceMonitor::ping()
}
if (!targetInterface.isValid()) {
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;
}
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)
@ -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();
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)
@ -116,6 +119,10 @@ void DeviceMonitor::pingFinished(int exitCode)
emit seen();
} else {
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
QString data = QString::fromLatin1(m_pingProcess->readAll());

View File

@ -82,6 +82,7 @@ DeviceManager::DeviceSetupStatus DevicePluginNetworkDetector::setupDevice(Device
connect(monitor, &DeviceMonitor::addressChanged, this, &DevicePluginNetworkDetector::deviceAddressChanged);
connect(monitor, &DeviceMonitor::seen, this, &DevicePluginNetworkDetector::deviceSeen);
m_monitors.insert(monitor, device);
monitor->update();
return DeviceManager::DeviceSetupStatusSuccess;
}

View File

@ -43,8 +43,7 @@
"displayName": "Device is present",
"displayNameEvent": "Device is present changed",
"type": "bool",
"defaultValue": false,
"cached": false
"defaultValue": false
},
{
"id": "b51d54c9-cce1-43f0-a35d-52fc2d8d302c",