Commit 22410ac3 authored by flypig's avatar flypig

[qtbase] Check alternative connections when connecting. Contributes to JB#47349

QNetworkAccessManager keeps track of a single connected session (e.g.
Wifi, mobile data) at a time. If the currently tracked session
disconnects, it checks whether any other network configuration is
online, and if so, it switches to make this the current session.

However, if the currently tracked session changes to the Connecting
state, QNetworkAccessManager will claim the network is inaccessible,
even if other configurations are online, and will refuse to switch to a
different session until the current session state changes from
Connecting to either Connected or Disconnected.

Unfortunately, occassionally Wifi connections will move into the
Connecting state and potentially not switch to the Connected or
Disconnected state for some time, which can block connectivity for apps
using QNetworkAccessManager to maintain connections (it's not clear
whether this is because the connection actually gets stuck, or because
the state change signals get lost somewhere; the result is the
same).

This change makes QNetworkAccessManager switch connection in case the
current session moves to the Connecting state while another online
configuration is available to use instead.
parent 7a6bb23f
......@@ -1651,11 +1651,6 @@ void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession
Q_Q(QNetworkAccessManager);
qCDebug(lcNetworkAccess) << "QNAM: network session state changed:" << state;
if ((state == QNetworkSession::Connecting) && (!getNetworkSession())) {
qCWarning(lcNetworkAccess) << "QNAM: ignoring Connecting state received after the session closed";
return;
}
bool reallyOnline = false;
//Do not emit the networkSessionConnected signal here, except for roaming -> connected
//transition, otherwise it is emitted twice in a row when opening a connection.
......@@ -1663,7 +1658,7 @@ void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession
emit q->networkSessionConnected();
lastSessionState = state;
if (state == QNetworkSession::Disconnected) {
if ((state == QNetworkSession::Disconnected) || (state == QNetworkSession::Connecting)) {
Q_FOREACH (const QNetworkConfiguration &cfg, networkConfigurationManager.allConfigurations()) {
if (cfg.state().testFlag(QNetworkConfiguration::Active)) {
reallyOnline = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment