summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorMatt Broadstone <mbroadstone@devonit.com>2014-08-18 21:02:52 (GMT)
committerMatt Broadstone <mbroadst@gmail.com>2014-08-18 21:48:44 (GMT)
commitc830cfab4f9b264c26c0111fe923562b82f72fed (patch)
tree6c41a9eca622f831a98d50b299ebe484cf87a1d3 /src/network/access
parent469dcfff3e39249b0a5eb98242fbe5f917587246 (diff)
downloadQt-c830cfab4f9b264c26c0111fe923562b82f72fed.zip
Qt-c830cfab4f9b264c26c0111fe923562b82f72fed.tar.gz
Qt-c830cfab4f9b264c26c0111fe923562b82f72fed.tar.bz2
refactor disconnectFromFtp to remove cached entries when necessary
In cases where a cached ftp connection fails to connect, or a file transfer has failed, we should removed the cached connection. Since qnam has an idea of a single internal QFtp per full operation, when file transfers failed previously the cached connection would be reused for subsequent connections and thus fail. [ChangeLog][QtNetwork][QNetworkAccessManager] QNetworkAccessManager now properly handles FTP transfer failures by removing failed cached ftp connections. Task-number: QTBUG-40797 (cherry picked and adapted from qtbase/45cbbe56bc13216b83215ea148590eccf81f420a) Change-Id: Ie9eec5ec54af16a8d19e34d04bdd993cc7bbd0f5 Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp20
-rw-r--r--src/network/access/qnetworkaccessftpbackend_p.h7
2 files changed, 15 insertions, 12 deletions
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index 449a51e..541f8f4 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -205,7 +205,7 @@ void QNetworkAccessFtpBackend::ftpConnectionReady(QNetworkAccessCache::Cacheable
// no, defer the actual operation until after we've logged in
}
-void QNetworkAccessFtpBackend::disconnectFromFtp()
+void QNetworkAccessFtpBackend::disconnectFromFtp(CacheCleanupMode mode)
{
state = Disconnecting;
@@ -213,7 +213,12 @@ void QNetworkAccessFtpBackend::disconnectFromFtp()
disconnect(ftp, 0, this, 0);
QByteArray key = makeCacheKey(url());
- QNetworkAccessManagerPrivate::getObjectCache(this)->releaseEntry(key);
+ if (mode == RemoveCachedConnection) {
+ QNetworkAccessManagerPrivate::getObjectCache(this)->removeEntry(key);
+ ftp->dispose();
+ } else {
+ QNetworkAccessManagerPrivate::getObjectCache(this)->releaseEntry(key);
+ }
ftp = 0;
}
@@ -263,14 +268,7 @@ void QNetworkAccessFtpBackend::ftpDone()
}
// we're not connected, so remove the cache entry:
- QByteArray key = makeCacheKey(url());
- QNetworkAccessManagerPrivate::getObjectCache(this)->removeEntry(key);
-
- disconnect(ftp, 0, this, 0);
- ftp->dispose();
- ftp = 0;
-
- state = Disconnecting;
+ disconnectFromFtp(RemoveCachedConnection);
finished();
return;
}
@@ -290,7 +288,7 @@ void QNetworkAccessFtpBackend::ftpDone()
else
error(QNetworkReply::ContentAccessDenied, msg);
- disconnectFromFtp();
+ disconnectFromFtp(RemoveCachedConnection);
finished();
}
diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h
index e64e2b4..ea5cda3 100644
--- a/src/network/access/qnetworkaccessftpbackend_p.h
+++ b/src/network/access/qnetworkaccessftpbackend_p.h
@@ -90,7 +90,12 @@ public:
virtual void downstreamReadyWrite();
- void disconnectFromFtp();
+ enum CacheCleanupMode {
+ ReleaseCachedConnection,
+ RemoveCachedConnection
+ };
+
+ void disconnectFromFtp(CacheCleanupMode mode = ReleaseCachedConnection);
public slots:
void ftpConnectionReady(QNetworkAccessCache::CacheableObject *object);