summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 04:40:21 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 04:40:21 +0000
commit1d04d7299fa371256bfa07dc4c9efd1553b0792f (patch)
treefc15bd500994632604de8daeb27f17d92b891ad9 /net
parent7fff3291749da0ed6cc82188b42019b3d3be91cf (diff)
downloadchromium_src-1d04d7299fa371256bfa07dc4c9efd1553b0792f.zip
chromium_src-1d04d7299fa371256bfa07dc4c9efd1553b0792f.tar.gz
chromium_src-1d04d7299fa371256bfa07dc4c9efd1553b0792f.tar.bz2
net: Use ClosePlatformFile() instead of close/CloseHandle().
ClosePlatformFile() is guarded with ThreadRestrictions::AssertIOAllowed() that will catch bad pieces of code performing file IO on wrong threads. The original patch was reverted as it broke tests in debug builds. This version contains workarounds for the bad pieces of code. BUG=59849,72001,75548,112474,112512 TEST=try bots both release and debug Review URL: http://codereview.chromium.org/9315062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/file_stream_posix.cc3
-rw-r--r--net/base/file_stream_win.cc3
-rw-r--r--net/url_request/url_request_file_job.cc3
3 files changed, 6 insertions, 3 deletions
diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc
index 502d0f1..a094eed 100644
--- a/net/base/file_stream_posix.cc
+++ b/net/base/file_stream_posix.cc
@@ -353,9 +353,8 @@ void FileStream::Close() {
async_context_.reset();
if (file_ != base::kInvalidPlatformFileValue) {
- if (close(file_) != 0) {
+ if (!base::ClosePlatformFile(file_))
NOTREACHED();
- }
file_ = base::kInvalidPlatformFileValue;
bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL);
diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc
index 1f7ecbf..9e1f686f 100644
--- a/net/base/file_stream_win.cc
+++ b/net/base/file_stream_win.cc
@@ -181,7 +181,8 @@ void FileStream::Close() {
async_context_.reset();
if (file_ != INVALID_HANDLE_VALUE) {
- CloseHandle(file_);
+ if (!base::ClosePlatformFile(file_))
+ NOTREACHED();
file_ = INVALID_HANDLE_VALUE;
bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL);
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index d8187ab..8f32750 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -158,6 +158,9 @@ void URLRequestFileJob::Start() {
}
void URLRequestFileJob::Kill() {
+ // URL requests should not block on the disk!
+ // http://code.google.com/p/chromium/issues/detail?id=59849
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
stream_.Close();
if (async_resolver_) {