Fix various performance and stability issues in the network-manager backend

pull/16/head
Timothy Pearson 12 years ago
parent 2277bfa0d6
commit 9e5d27963b

@ -1332,7 +1332,7 @@ void TDENetworkConnectionManager_BackendNM_DBusSignalReceiver::dbusSignal(const
TQString member = message.member();
TQString path = message.path();
// printf("[DEBUG] In dbusSignal: sender: %s, member: %s, interface: %s, path: %s\n\r", sender.ascii(), member.ascii(), interface.ascii(), path.ascii()); fflush(stdout);
// printf("[DEBUG] In dbusSignal: sender: %s, member: %s, interface: %s, path: %s, parent path: %s\n\r", sender.ascii(), member.ascii(), interface.ascii(), path.ascii(), m_parent->m_dbusDeviceString.ascii()); fflush(stdout);
if (interface == NM_VPN_DBUS_CONNECTION_SERVICE) {
if (member == "VpnStateChanged") {
@ -1711,6 +1711,31 @@ TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceInforma
return ret;
}
TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceStatus() {
TQT_DBusError error;
TDENetworkDeviceInformation ret;
if (d->m_networkDeviceProxy) {
ret.statusFlags = nmDeviceStateToTDEDeviceState(d->m_networkDeviceProxy->getState(error));
ret.UUID = d->m_networkDeviceProxy->getUdi(error);
// Get active connection UUID
TQT_DBusObjectPath connectionPath = d->m_networkDeviceProxy->getActiveConnection(error);
if (!error.isValid()) {
DBus::ActiveConnectionProxy activeConnection(NM_DBUS_SERVICE, connectionPath);
activeConnection.setConnection(TQT_DBusConnection::systemBus());
ret.activeConnectionUUID = activeConnection.getUuid(error);
if (!error.isValid()) {
ret.activeConnectionUUID = TQString::null;
}
}
ret.valid = true;
}
return ret;
}
void TDENetworkConnectionManager_BackendNMPrivate::processConnectionSettingsAsyncReply(int asyncCallId, const TQT_DBusDataMap<TQString>& settings) {
nmConnectionSettingsAsyncCallWaiting[asyncCallId] = false;
nmConnectionSettingsAsyncSettingsResponse[asyncCallId] = settings;
@ -4660,7 +4685,9 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
}
return checkConnectionStatus(uuid);
#else // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
connect(d->m_networkManagerProxy, SIGNAL(ActivateConnectionAsyncReply(int, const TQT_DBusObjectPath&)), d, SLOT(processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&)));
#endif // WAIT_FOR_OPERATION_BEFORE_RETURNING
int asyncCallID;
ret = d->m_networkManagerProxy->ActivateConnectionAsync(asyncCallID, existingConnection, TQT_DBusObjectPath(d->m_dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), error);
if (ret && error.isValid()) {
@ -4841,7 +4868,9 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
}
return checkConnectionStatus(uuid);
#else // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
connect(d->m_networkManagerProxy, SIGNAL(DeactivateConnectionAsyncReply(int)), d, SLOT(processConnectionSettingsUpdateAsyncReply(int)));
#endif // WAIT_FOR_OPERATION_BEFORE_RETURNING
int asyncCallID;
ret = d->m_networkManagerProxy->DeactivateConnectionAsync(asyncCallID, existingConnection, error);
if (ret && error.isValid()) {

@ -159,6 +159,7 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
virtual TDENetworkDeviceType::TDENetworkDeviceType deviceType();
virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus();
virtual TDENetworkDeviceInformation deviceInformation();
virtual TDENetworkDeviceInformation deviceStatus();
virtual void loadConnectionInformation();
virtual void loadConnectionAllowedValues(TDENetworkConnection* connection);

@ -21,8 +21,12 @@
#include "config.h"
#include <tqtimer.h>
#include <klocale.h>
// #define DEBUG_SIGNAL_QUEUE 1
#ifdef WITH_NETWORK_MANAGER_BACKEND
#include "networkbackends/network-manager/network-manager.h"
#endif // WITH_NETWORK_MANAGER_BACKEND
@ -684,11 +688,14 @@ TDEWiFiConnection::~TDEWiFiConnection() {
/*================================================================================================*/
TDENetworkConnectionManager::TDENetworkConnectionManager(TQString macAddress) : TQObject(), m_connectionList(NULL), m_hwNeighborList(NULL), m_macAddress(macAddress), m_prevConnectionStatus(TDENetworkGlobalManagerFlags::Unknown) {
//
m_emissionTimer = new TQTimer();
connect(m_emissionTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(emitQueuedSignals()));
if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
TDENetworkConnectionManager::~TDENetworkConnectionManager() {
//
m_emissionTimer->stop();
delete m_emissionTimer;
}
TQString TDENetworkConnectionManager::deviceMACAddress() {
@ -828,7 +835,13 @@ void TDENetworkConnectionManager::clearTDENetworkHWNeighborList() {
}
void TDENetworkConnectionManager::internalNetworkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState) {
emit(networkConnectionStateChanged(m_prevConnectionStatus, newState));
TDENetworkEventQueueEvent_Private queuedEvent;
queuedEvent.eventType = 0;
queuedEvent.newState = newState;
queuedEvent.previousState = m_prevConnectionStatus;
m_globalEventQueueEventList.append(queuedEvent);
if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
m_prevConnectionStatus = newState;
}
@ -836,24 +849,86 @@ void TDENetworkConnectionManager::internalNetworkDeviceStateChanged(TDENetworkCo
if (!m_prevDeviceStatus.contains(hwAddress)) {
m_prevDeviceStatus[hwAddress] = TDENetworkConnectionStatus::Invalid;
}
emit(networkDeviceStateChanged(newState, m_prevDeviceStatus[hwAddress], hwAddress));
TDENetworkEventQueueEvent_Private queuedEvent;
queuedEvent.eventType = 1;
queuedEvent.newConnStatus = newState;
queuedEvent.previousConnStatus = m_prevDeviceStatus[hwAddress];
queuedEvent.hwAddress = hwAddress;
m_globalEventQueueEventList.append(queuedEvent);
if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
m_prevDeviceStatus[hwAddress] = newState;
}
void TDENetworkConnectionManager::internalAccessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event) {
emit(accessPointStatusChanged(BSSID, event));
TDENetworkEventQueueEvent_Private queuedEvent;
queuedEvent.eventType = 2;
queuedEvent.BSSID = BSSID;
queuedEvent.apevent = event;
m_globalEventQueueEventList.append(queuedEvent);
if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
void TDENetworkConnectionManager::internalNetworkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event, TQString message) {
emit(networkDeviceEvent(event, message));
TDENetworkEventQueueEvent_Private queuedEvent;
queuedEvent.eventType = 3;
queuedEvent.ndevent = event;
queuedEvent.message = message;
m_globalEventQueueEventList.append(queuedEvent);
if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
void TDENetworkConnectionManager::internalVpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message) {
emit(vpnEvent(event, message));
TDENetworkEventQueueEvent_Private queuedEvent;
queuedEvent.eventType = 4;
queuedEvent.vpnevent = event;
queuedEvent.message = message;
m_globalEventQueueEventList.append(queuedEvent);
if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
void TDENetworkConnectionManager::internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event) {
emit(networkManagementEvent(event));
TDENetworkEventQueueEvent_Private queuedEvent;
queuedEvent.eventType = 5;
queuedEvent.globalevent = event;
m_globalEventQueueEventList.append(queuedEvent);
if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
void TDENetworkConnectionManager::emitQueuedSignals() {
if (!m_globalEventQueueEventList.isEmpty()) {
#ifdef DEBUG_SIGNAL_QUEUE
kdDebug() << "TDENetworkConnectionManager::emitQueuedSignals: Going to dequeue " << m_globalEventQueueEventList.count() << " events..." << endl;
#endif // DEBUG_SIGNAL_QUEUE
TDENetworkEventQueueEvent_PrivateList::Iterator it;
it = m_globalEventQueueEventList.begin();
while (it != m_globalEventQueueEventList.end()) {
TDENetworkEventQueueEvent_Private event = (*it);
it = m_globalEventQueueEventList.remove(it);
if (event.eventType == 0) {
emit(networkConnectionStateChanged(event.newState, event.previousState));
}
else if (event.eventType == 1) {
emit(networkDeviceStateChanged(event.newConnStatus, event.previousConnStatus, event.hwAddress));
}
else if (event.eventType == 2) {
emit(accessPointStatusChanged(event.BSSID, event.apevent));
}
else if (event.eventType == 3) {
emit(networkDeviceEvent(event.ndevent, event.message));
}
else if (event.eventType == 4) {
emit(vpnEvent(event.vpnevent, event.message));
}
else if (event.eventType == 5) {
emit(networkManagementEvent(event.globalevent));
}
}
#ifdef DEBUG_SIGNAL_QUEUE
kdDebug() << "TDENetworkConnectionManager::emitQueuedSignals: " << m_globalEventQueueEventList.count() << " events remain in queue" << endl;
#endif // DEBUG_SIGNAL_QUEUE
}
}
/*================================================================================================*/

@ -990,6 +990,29 @@ class TDECORE_EXPORT TDEModemConnection : public TDENetworkConnection
typedef TQPtrList< TDENetworkConnection > TDENetworkConnectionList;
/**
* INTERNAL CLASS
*/
class TDENetworkEventQueueEvent_Private
{
public:
int eventType;
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState;
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags previousState;
TDENetworkConnectionStatus::TDENetworkConnectionStatus newConnStatus;
TDENetworkConnectionStatus::TDENetworkConnectionStatus previousConnStatus;
TDEMACAddress BSSID;
TQString message;
TQString hwAddress;
TDENetworkAPEventType::TDENetworkAPEventType apevent;
TDENetworkDeviceEventType::TDENetworkDeviceEventType ndevent;
TDENetworkVPNEventType::TDENetworkVPNEventType vpnevent;
TDENetworkGlobalEventType::TDENetworkGlobalEventType globalevent;
};
typedef TQValueList<TDENetworkEventQueueEvent_Private> TDENetworkEventQueueEvent_PrivateList;
class TQTimer;
class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
{
Q_OBJECT
@ -1024,10 +1047,20 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus() = 0;
/**
* @return A TDENetworkDeviceInformation object containing the current status of the network device.
* @return A TDENetworkDeviceInformation object containing the current configuration and status of the network device.
*/
virtual TDENetworkDeviceInformation deviceInformation() = 0;
/**
* @return A TDENetworkDeviceInformation object containing a (limited) current status of the network device.
* Only the following object fields are populated:
* statusFlags
* UUID
* activeConnectionUUID
* valid
*/
virtual TDENetworkDeviceInformation deviceStatus() = 0;
/**
* Loads all connection information from the configuration backend
* Secret information must be loaded separately via a call to
@ -1311,12 +1344,17 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/
void internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event);
protected slots:
void emitQueuedSignals();
protected:
TDENetworkConnectionList* m_connectionList;
TDENetworkHWNeighborList* m_hwNeighborList;
TQString m_macAddress;
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags m_prevConnectionStatus;
TQMap<TQString, TDENetworkConnectionStatus::TDENetworkConnectionStatus> m_prevDeviceStatus;
TQTimer* m_emissionTimer;
TDENetworkEventQueueEvent_PrivateList m_globalEventQueueEventList;
};
class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject

Loading…
Cancel
Save