diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 23:25:04 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 23:25:04 +0000 |
commit | dba635a4500b6f345d1bd7639d5e7144e037e11f (patch) | |
tree | 2a7e6a575038ecf4e82d22851f4cedb57d7f2409 /chrome/common/resource_dispatcher.cc | |
parent | 45e71eff71b7e4310f9cd731a7251b3b90090c84 (diff) | |
download | chromium_src-dba635a4500b6f345d1bd7639d5e7144e037e11f.zip chromium_src-dba635a4500b6f345d1bd7639d5e7144e037e11f.tar.gz chromium_src-dba635a4500b6f345d1bd7639d5e7144e037e11f.tar.bz2 |
When cancelling a pending request, release any outstanding SharedIOBuffer
objects and their associated shared memory segments. This avoids a shared
memory leak and file descriptor leak.
BUG=38383
TEST=Using test_chrome_fd_leak from bug 38383 and lsof, the renderer process
should not show an fd leak on Mac or Linux.
Review URL: http://codereview.chromium.org/1703017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46007 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/resource_dispatcher.cc')
-rw-r--r-- | chrome/common/resource_dispatcher.cc | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc index 5c2fd28..b0d2918 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -484,17 +484,10 @@ bool ResourceDispatcher::RemovePendingRequest(int request_id) { if (it == pending_requests_.end()) return false; - // Iterate through the deferred message queue and clean up the messages. PendingRequestInfo& request_info = it->second; - MessageQueue& q = request_info.deferred_message_queue; - while (!q.empty()) { - IPC::Message* m = q.front(); - ReleaseResourcesInDataMessage(*m); - q.pop_front(); - delete m; - } - + ReleaseResourcesInMessageQueue(&request_info.deferred_message_queue); pending_requests_.erase(it); + return true; } @@ -502,14 +495,14 @@ void ResourceDispatcher::CancelPendingRequest(int routing_id, int request_id) { PendingRequestList::iterator it = pending_requests_.find(request_id); if (it == pending_requests_.end()) { - DLOG(ERROR) << "unknown request"; + DLOG(WARNING) << "unknown request"; return; } + PendingRequestInfo& request_info = it->second; - // Avoid spamming the host with cancel messages. - if (request_info.is_cancelled) - return; - request_info.is_cancelled = true; + ReleaseResourcesInMessageQueue(&request_info.deferred_message_queue); + pending_requests_.erase(it); + message_sender()->Send( new ViewHostMsg_CancelRequest(routing_id, request_id)); } @@ -598,6 +591,7 @@ bool ResourceDispatcher::IsResourceDispatcherMessage( return false; } +// static void ResourceDispatcher::ReleaseResourcesInDataMessage( const IPC::Message& message) { void* iter = NULL; @@ -618,3 +612,13 @@ void ResourceDispatcher::ReleaseResourcesInDataMessage( } } } + +// static +void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { + while (!queue->empty()) { + IPC::Message* message = queue->front(); + ReleaseResourcesInDataMessage(*message); + queue->pop_front(); + delete message; + } +} |