QNetworkAccessManager was using the AutoCloseConnection property
of QNetworkSession to close it when idle. However this property is
only implemented for polling engines and not event driven engines.
Instead, release the network session reference.
If another request comes in, it will be resurrected from the shared
session weak reference.
If not, then after 2 minutes when the connection caches are flushed
the ref count will reach zero and cause the QNetworkSession to be
destroyed (which closes it)
Task-number: QTBUG-15812
Change-Id: I2963bdf13fb02e3ac269489ea463669142f3c5f3
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
d->initializeSession = false;
}
}
-
- if (d->networkSession)
- d->networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), -1);
#endif
QNetworkRequest request = req;
emit q->finished(reply);
#ifndef QT_NO_BEARERMANAGEMENT
+ // If there are no active requests, release our reference to the network session.
+ // It will not be destroyed immediately, but rather when the connection cache is flushed
+ // after 2 minutes.
if (networkSession && q->findChildren<QNetworkReply *>().count() == 1)
- networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), 120000);
+ networkSession.clear();
#endif
}