diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2015-11-12 16:24:00 -0500 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2015-11-13 14:37:17 -0500 |
commit | 66e1d33168fd7aaa4e504050d558c2244a261ca7 (patch) | |
tree | 38fd4a5a40c18577bb76d4ea282556f1568bc36b | |
parent | 8582120194ff7e6fe42cf2fe515712f5a979bf9e (diff) | |
download | qtlocation-mapboxgl-66e1d33168fd7aaa4e504050d558c2244a261ca7.tar.gz |
[node] always destruct canceled requests, don't exit early
-rw-r--r-- | platform/node/src/node_file_source.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/platform/node/src/node_file_source.cpp b/platform/node/src/node_file_source.cpp index 1b05b142de..eab664ebcf 100644 --- a/platform/node/src/node_file_source.cpp +++ b/platform/node/src/node_file_source.cpp @@ -60,16 +60,13 @@ void NodeFileSource::cancel(Request* req) { std::lock_guard<std::mutex> lock(observersMutex); auto it = observers.find(req->resource); - if (it == observers.end()) { - // Exit early if no observers are found. - return; - } - - observers.erase(it); + if (it != observers.end()) { + observers.erase(it); - // This function can be called from any thread. Make sure we're executing the actual call in the - // file source loop by sending it over the queue. - queue->send(Action{ Action::Cancel, req->resource }); + // This function can be called from any thread. Make sure we're executing the actual call in the + // file source loop by sending it over the queue. + queue->send(Action{ Action::Cancel, req->resource }); + } // Send a message back to the requesting thread and notify it that this request has been // canceled and is now safe to be deleted. @@ -137,12 +134,9 @@ void NodeFileSource::notify(const Resource& resource, const std::shared_ptr<cons std::lock_guard<std::mutex> lock(observersMutex); auto observersIt = observers.find(resource); - if (observersIt == observers.end()) { - // Exit early if no observers are found. - return; + if (observersIt != observers.end()) { + observersIt->second->notify(response); } - - observersIt->second->notify(response); } } |