summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/symbian
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-05-26 04:24:26 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-05-31 05:11:18 (GMT)
commit745e276f6802f0f7fb2d548d04bf120c5516d7c6 (patch)
tree31f7862d426ae8faddab657959ea7af81d8103d9 /src/plugins/bearer/symbian
parentd0e1e7c1249348eeba128c71681cfa916c9e5ae1 (diff)
downloadQt-745e276f6802f0f7fb2d548d04bf120c5516d7c6.zip
Qt-745e276f6802f0f7fb2d548d04bf120c5516d7c6.tar.gz
Qt-745e276f6802f0f7fb2d548d04bf120c5516d7c6.tar.bz2
Fix locking after merge from Qt Mobility.
Simplify locking by using inline getter functions. Task-number: QTBUG-10296
Diffstat (limited to 'src/plugins/bearer/symbian')
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.cpp102
-rw-r--r--src/plugins/bearer/symbian/symbianengine.cpp70
-rw-r--r--src/plugins/bearer/symbian/symbianengine.h18
3 files changed, 88 insertions, 102 deletions
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
index 3cd18fb..e08d135 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
@@ -122,19 +122,10 @@ void QNetworkSessionPrivateImpl::configurationRemoved(QNetworkConfigurationPriva
if (!publicConfig.isValid())
return;
- SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(config);
-
- symbianConfig->mutex.lock();
- TUint32 configNumericId = symbianConfig->numericId;
- symbianConfig->mutex.unlock();
-
- symbianConfig = toSymbianConfig(privateConfiguration(publicConfig));
-
- symbianConfig->mutex.lock();
- TUint32 publicNumericId = symbianConfig->numericId;
- symbianConfig->mutex.unlock();
+ TUint32 publicNumericId =
+ toSymbianConfig(privateConfiguration(publicConfig))->numericIdentifier();
- if (configNumericId == publicNumericId) {
+ if (toSymbianConfig(config)->numericIdentifier() == publicNumericId) {
#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
qDebug() << "QNS this : " << QString::number((uint)this) << " - "
<< "configurationRemoved IAP: " << QString::number(publicNumericId) << " : going to State: Invalid";
@@ -380,13 +371,11 @@ void QNetworkSessionPrivateImpl::open()
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(publicConfig));
- QMutexLocker configLocker(&symbianConfig->mutex);
-
- if (connInfo().iIapId == symbianConfig->numericId) {
+ if (connInfo().iIapId == symbianConfig->numericIdentifier()) {
if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) {
activeConfig = publicConfig;
#ifndef QT_NO_NETWORKINTERFACE
- activeInterface = interface(symbianConfig->numericId);
+ activeInterface = interface(symbianConfig->numericIdentifier());
#endif
connected = ETrue;
startTime = QDateTime::currentDateTime();
@@ -416,9 +405,7 @@ void QNetworkSessionPrivateImpl::open()
TConnPrefList pref;
TExtendedConnPref prefs;
- symbianConfig->mutex.lock();
- prefs.SetIapId(symbianConfig->numericId);
- symbianConfig->mutex.unlock();
+ prefs.SetIapId(symbianConfig->numericIdentifier());
if (iConnectInBackground) {
prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent );
}
@@ -427,9 +414,7 @@ void QNetworkSessionPrivateImpl::open()
TCommDbConnPref pref;
pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
- symbianConfig->mutex.lock();
- pref.SetIapId(symbianConfig->numericId);
- symbianConfig->mutex.unlock();
+ pref.SetIapId(symbianConfig->numericIdentifier());
#endif
iConnection.Start(pref, iStatus);
if (!IsActive()) {
@@ -444,17 +429,13 @@ void QNetworkSessionPrivateImpl::open()
#ifdef OCC_FUNCTIONALITY_AVAILABLE
TConnPrefList snapPref;
TExtendedConnPref prefs;
- symbianConfig->mutex.lock();
- prefs.SetSnapId(symbianConfig->numericId);
- symbianConfig->mutex.unlock();
+ prefs.SetSnapId(symbianConfig->numericIdentifier());
if (iConnectInBackground) {
prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent );
}
snapPref.AppendL(&prefs);
#else
- symbianConfig->mutex.lock();
- TConnSnapPref snapPref(symbianConfig->numericId);
- symbianConfig->mutex.unlock();
+ TConnSnapPref snapPref(symbianConfig->numericIdentifier());
#endif
iConnection.Start(snapPref, iStatus);
if (!IsActive()) {
@@ -592,10 +573,8 @@ void QNetworkSessionPrivateImpl::stop()
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(publicConfig));
- QMutexLocker configLocker(&symbianConfig->mutex);
-
// See if connection Id matches with our Id. If so, stop() it.
- if (symbianConfig->connectionId == connectionId) {
+ if (symbianConfig->connectionIdentifier() == connectionId) {
ret = iConnectionMonitor.SetBoolAttribute(connectionId,
0, // subConnectionId don't care
KConnectionStop,
@@ -715,12 +694,8 @@ void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOld
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(configs[i]));
- QMutexLocker configLocker(&symbianConfig->mutex);
-
- if (symbianConfig->numericId == aNewAPInfo.AccessPoint()) {
- configLocker.unlock();
+ if (symbianConfig->numericIdentifier() == aNewAPInfo.AccessPoint())
emit preferredConfigurationChanged(configs[i], aIsSeamless);
- }
}
} else {
migrate();
@@ -854,9 +829,7 @@ quint64 QNetworkSessionPrivateImpl::transferredData(TUint dataType) const
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(configs[i]));
- QMutexLocker configLocker(&symbianConfig->mutex);
-
- if (symbianConfig->numericId == apId) {
+ if (symbianConfig->numericIdentifier() == apId) {
configFound = true;
break;
}
@@ -865,10 +838,8 @@ quint64 QNetworkSessionPrivateImpl::transferredData(TUint dataType) const
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(config));
- symbianConfig->mutex.lock();
- if (symbianConfig->numericId == apId)
+ if (symbianConfig->numericIdentifier() == apId)
configFound = true;
- symbianConfig->mutex.unlock();
}
if (configFound) {
TUint tData;
@@ -908,8 +879,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia
SymbianNetworkConfigurationPrivate *childConfig =
toSymbianConfig(privateConfiguration(children[i]));
- QMutexLocker childLocker(&childConfig->mutex);
- if (childConfig->numericId == iapId)
+ if (childConfig->numericIdentifier() == iapId)
return children[i];
}
@@ -928,15 +898,11 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(pt));
if (symbianConfig) {
- QMutexLocker configLocker(&symbianConfig->mutex);
-
for (int i=0; i < children.count(); i++) {
SymbianNetworkConfigurationPrivate *childConfig =
toSymbianConfig(privateConfiguration(children[i]));
- QMutexLocker childLocker(&childConfig->mutex);
-
- if (childConfig->mappingName == symbianConfig->mappingName) {
+ if (childConfig->configMappingName() == symbianConfig->configMappingName()) {
return children[i];
}
}
@@ -1034,15 +1000,13 @@ void QNetworkSessionPrivateImpl::RunL()
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(activeConfig));
- symbianConfig->mutex.lock();
#ifndef QT_NO_NETWORKINTERFACE
- activeInterface = interface(symbianConfig->numericId);
+ activeInterface = interface(symbianConfig->numericIdentifier());
#endif
if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
serviceConfig = QNetworkConfigurationManager()
- .configurationFromIdentifier(symbianConfig->id);
+ .configurationFromIdentifier(activeConfig.identifier());
}
- symbianConfig->mutex.unlock();
startTime = QDateTime::currentDateTime();
@@ -1105,13 +1069,11 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint
newState == QNetworkSession::Connected) {
activeConfig = activeConfiguration(accessPointId);
+#ifndef QT_NO_NETWORKINTERFACE
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(activeConfig));
-#ifndef QT_NO_NETWORKINTERFACE
- symbianConfig->mutex.lock();
- activeInterface = interface(symbianConfig->numericId);
- symbianConfig->mutex.unlock();
+ activeInterface = interface(symbianConfig->numericIdentifier());
#endif
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
@@ -1187,10 +1149,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(publicConfig));
- QMutexLocker configLocker(&symbianConfig->mutex);
- if (symbianConfig->numericId == accessPointId) {
- configLocker.unlock();
-
+ if (symbianConfig->numericIdentifier() == accessPointId) {
state = newState;
#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed B to: " << state;
@@ -1202,10 +1161,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(activeConfig));
- QMutexLocker configLocker(&symbianConfig->mutex);
- if (symbianConfig->numericId == accessPointId) {
- configLocker.unlock();
-
+ if (symbianConfig->numericIdentifier() == accessPointId) {
state = newState;
#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed C to: " << state;
@@ -1219,9 +1175,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(subConfigurations[i]));
- QMutexLocker configLocker(&symbianConfig->mutex);
-
- if (symbianConfig->numericId == accessPointId) {
+ if (symbianConfig->numericIdentifier() == accessPointId) {
if (newState != QNetworkSession::Disconnected) {
state = newState;
#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
@@ -1234,8 +1188,6 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint
if ((config.state() == QNetworkConfiguration::Defined) ||
(config.state() == QNetworkConfiguration::Discovered)) {
- configLocker.unlock();
-
state = newState;
#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed E to: " << state;
@@ -1271,9 +1223,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint
SymbianNetworkConfigurationPrivate *symbianConfig =
toSymbianConfig(privateConfiguration(publicConfig));
- symbianConfig->mutex.lock();
- iDeprecatedConnectionId = symbianConfig->connectionId;
- symbianConfig->mutex.unlock();
+ iDeprecatedConnectionId = symbianConfig->connectionIdentifier();
}
return retVal;
@@ -1369,7 +1319,11 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne
qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "reporting disconnection to manager.";
#endif
if (publicConfig.isValid()) {
- engine->configurationStateChangeReport(toSymbianConfig(privateConfiguration(publicConfig))->numericId, QNetworkSession::Disconnected);
+ SymbianNetworkConfigurationPrivate *symbianConfig =
+ toSymbianConfig(privateConfiguration(publicConfig));
+
+ engine->configurationStateChangeReport(symbianConfig->numericIdentifier(),
+ QNetworkSession::Disconnected);
}
break;
// Unhandled state
diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp
index cea8b67..ed6aee6 100644
--- a/src/plugins/bearer/symbian/symbianengine.cpp
+++ b/src/plugins/bearer/symbian/symbianengine.cpp
@@ -338,34 +338,35 @@ void SymbianEngine::updateConfigurationsL()
TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod));
if (error == KErrNone) {
QNetworkConfigurationPrivatePointer ptr(cpPriv);
- toSymbianConfig(ptr)->serviceNetworkPtr = privSNAP;
accessPointConfigurations.insert(ptr->id, ptr);
locker.unlock();
emit configurationAdded(ptr);
locker.relock();
+ QMutexLocker configLocker(&privSNAP->mutex);
privSNAP->serviceNetworkMembers.append(ptr);
}
} else {
knownConfigs.removeOne(iface);
// Check that IAP can be found from related SNAP's configuration list
bool iapFound = false;
+ QMutexLocker snapConfigLocker(&privSNAP->mutex);
for (int i = 0; i < privSNAP->serviceNetworkMembers.count(); i++) {
- if (toSymbianConfig(privSNAP->serviceNetworkMembers[i])->numericId == iapId) {
+ if (toSymbianConfig(privSNAP->serviceNetworkMembers[i])->numericIdentifier() ==
+ iapId) {
iapFound = true;
break;
}
}
- if (!iapFound) {
- toSymbianConfig(priv)->serviceNetworkPtr = privSNAP;
+ if (!iapFound)
privSNAP->serviceNetworkMembers.append(priv);
- }
}
CleanupStack::PopAndDestroy(&connectionMethod);
}
+ QMutexLocker snapConfigLocker(&privSNAP->mutex);
if (privSNAP->serviceNetworkMembers.count() > 1) {
// Roaming is supported only if SNAP contains more than one IAP
privSNAP->roamingSupported = true;
@@ -418,9 +419,10 @@ void SymbianEngine::updateConfigurationsL()
foreach (const QString &iface, snapConfigurations.keys()) {
QNetworkConfigurationPrivatePointer ptr2 = snapConfigurations.value(iface);
// => Check if one of the IAPs of the SNAP is active
+ QMutexLocker snapConfigLocker(&ptr2->mutex);
for (int i = 0; i < ptr2->serviceNetworkMembers.count(); ++i) {
- if (toSymbianConfig(ptr2->serviceNetworkMembers[i])->numericId ==
- toSymbianConfig(ptr)->numericId) {
+ if (toSymbianConfig(ptr2->serviceNetworkMembers[i])->numericIdentifier() ==
+ toSymbianConfig(ptr)->numericIdentifier()) {
ptr2->serviceNetworkMembers.removeAt(i);
break;
}
@@ -639,12 +641,14 @@ QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL()
}
#endif
- if (!ptr || !ptr->isValid) {
- QString iface = QString::number(qHash(KUserChoiceIAPId));
- ptr = userChoiceConfigurations.value(iface);
+ if (ptr) {
+ QMutexLocker configLocker(&ptr->mutex);
+ if (ptr->isValid)
+ return ptr;
}
-
- return ptr;
+
+ QString iface = QString::number(qHash(KUserChoiceIAPId));
+ return userChoiceConfigurations.value(iface);
}
void SymbianEngine::updateActiveAccessPoints()
@@ -681,8 +685,9 @@ void SymbianEngine::updateActiveAccessPoints()
online = true;
inactiveConfigs.removeOne(ident);
- QMutexLocker configLocker(&ptr->mutex);
+ ptr->mutex.lock();
toSymbianConfig(ptr)->connectionId = connectionId;
+ ptr->mutex.unlock();
// Configuration is Active
changeConfigurationStateTo(ptr, QNetworkConfiguration::Active);
@@ -736,6 +741,8 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident);
if (ptr) {
unavailableConfigs.removeOne(ident);
+
+ QMutexLocker configLocker(&ptr->mutex);
if (ptr->state < QNetworkConfiguration::Active) {
// Configuration is either Discovered or Active
changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered);
@@ -772,10 +779,15 @@ void SymbianEngine::updateStatesToSnaps()
bool discovered = false;
bool active = false;
QNetworkConfigurationPrivatePointer ptr = snapConfigurations.value(iface);
+
+ QMutexLocker snapConfigLocker(&ptr->mutex);
+
// => Check if one of the IAPs of the SNAP is discovered or active
// => If one of IAPs is active, also SNAP is active
// => If one of IAPs is discovered but none of the IAPs is active, SNAP is discovered
for (int i=0; i<ptr->serviceNetworkMembers.count(); i++) {
+ QMutexLocker configLocker(&ptr->serviceNetworkMembers[i]->mutex);
+
if ((ptr->serviceNetworkMembers[i]->state & QNetworkConfiguration::Active)
== QNetworkConfiguration::Active) {
active = true;
@@ -991,9 +1003,11 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
QString ident = QString::number(qHash(apId));
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident);
if (ptr) {
- QMutexLocker configLocker(&ptr->mutex);
+ ptr->mutex.lock();
toSymbianConfig(ptr)->connectionId = connectionId;
- emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connecting);
+ ptr->mutex.unlock();
+ emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(),
+ connectionId, QNetworkSession::Connecting);
}
} else if (connectionStatus == KLinkLayerOpen) {
// Connection has been successfully opened
@@ -1006,13 +1020,17 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
QString ident = QString::number(qHash(apId));
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident);
if (ptr) {
- QMutexLocker configLocker(&ptr->mutex);
+ ptr->mutex.lock();
toSymbianConfig(ptr)->connectionId = connectionId;
+ ptr->mutex.unlock();
+
// Configuration is Active
if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) {
updateStatesToSnaps();
}
- emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connected);
+ emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(),
+ connectionId, QNetworkSession::Connected);
+
if (!iOnline) {
iOnline = true;
emit this->onlineStateChanged(iOnline);
@@ -1022,8 +1040,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
TUint connectionId = realEvent->ConnectionId();
QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId);
if (ptr) {
- QMutexLocker configLocker(&ptr->mutex);
- emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Closing);
+ emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(),
+ connectionId, QNetworkSession::Closing);
}
} else if (connectionStatus == KLinkLayerClosed ||
connectionStatus == KConnectionClosed) {
@@ -1037,8 +1055,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
updateStatesToSnaps();
}
- QMutexLocker configLocker(&ptr->mutex);
- emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Disconnected);
+ emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(),
+ connectionId, QNetworkSession::Disconnected);
}
bool online = false;
@@ -1135,10 +1153,9 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo
updateStatesToSnaps();
}
- QMutexLocker configLocker(&ptr->mutex);
- emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId,
- toSymbianConfig(ptr)->connectionId,
- QNetworkSession::Disconnected);
+ emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(),
+ toSymbianConfig(ptr)->connectionIdentifier(),
+ QNetworkSession::Disconnected);
}
}
break;
@@ -1170,8 +1187,7 @@ QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aCon
accessPointConfigurations.constBegin();
while (i != accessPointConfigurations.constEnd()) {
QNetworkConfigurationPrivatePointer ptr = i.value();
- QMutexLocker configLocker(&ptr->mutex);
- if (toSymbianConfig(ptr)->connectionId == aConnectionId)
+ if (toSymbianConfig(ptr)->connectionIdentifier() == aConnectionId)
return ptr;
++i;
diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h
index 7d565db..841d79d 100644
--- a/src/plugins/bearer/symbian/symbianengine.h
+++ b/src/plugins/bearer/symbian/symbianengine.h
@@ -87,7 +87,23 @@ public:
QString bearerName() const;
- QNetworkConfigurationPrivatePointer serviceNetworkPtr;
+ inline TUint32 numericIdentifier() const
+ {
+ QMutexLocker locker(&mutex);
+ return numericId;
+ }
+
+ inline TUint connectionIdentifier() const
+ {
+ QMutexLocker locker(&mutex);
+ return connectionId;
+ }
+
+ inline QString configMappingName() const
+ {
+ QMutexLocker locker(&mutex);
+ return mappingName;
+ }
QString mappingName;