diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-09-16 15:43:53 +0200 |
---|---|---|
committer | Ivo van Dongen <info@ivovandongen.nl> | 2016-09-23 10:47:55 +0200 |
commit | 496904306681e0f77316fbfb9127129338a20e34 (patch) | |
tree | ce54d327d3c4a9c3c699454df2b11624a2d79aaa /platform/default | |
parent | 71c71e43e666fdf9534f057e81ef468e6643289b (diff) | |
download | qtlocation-mapboxgl-496904306681e0f77316fbfb9127129338a20e34.tar.gz |
[core] OnlineFileSource - prevent double scheduling of requests
Diffstat (limited to 'platform/default')
-rw-r--r-- | platform/default/online_file_source.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/platform/default/online_file_source.cpp b/platform/default/online_file_source.cpp index 049cbf5f8d..00c66f004d 100644 --- a/platform/default/online_file_source.cpp +++ b/platform/default/online_file_source.cpp @@ -77,6 +77,7 @@ public: pendingRequestsMap.erase(it); } } + assert(pendingRequestsMap.size() == pendingRequestsList.size()); } void activateOrQueueRequest(OnlineFileRequest* request) { @@ -94,6 +95,7 @@ public: void queueRequest(OnlineFileRequest* request) { auto it = pendingRequestsList.insert(pendingRequestsList.end(), request); pendingRequestsMap.emplace(request, std::move(it)); + assert(pendingRequestsMap.size() == pendingRequestsList.size()); } void activateRequest(OnlineFileRequest* request) { @@ -104,6 +106,7 @@ public: request->request.reset(); request->completed(response); }); + assert(pendingRequestsMap.size() == pendingRequestsList.size()); } void activatePendingRequest() { @@ -117,6 +120,15 @@ public: pendingRequestsMap.erase(request); activateRequest(request); + assert(pendingRequestsMap.size() == pendingRequestsList.size()); + } + + bool isPending(OnlineFileRequest* request) { + return pendingRequestsMap.find(request) != pendingRequestsMap.end(); + } + + bool isActive(OnlineFileRequest* request) { + return activeRequests.find(request) != activeRequests.end(); } private: @@ -238,7 +250,7 @@ Timestamp interpolateExpiration(const Timestamp& current, } void OnlineFileRequest::schedule(optional<Timestamp> expires) { - if (request) { + if (impl.isPending(this) || impl.isActive(this)) { // There's already a request in progress; don't start another one. return; } |