From b0df57cf1f90cd46703023be0f6ab8c6175f7771 Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Sat, 15 Mar 2014 13:35:06 +0000 Subject: Revert of Implement ScopedFD in terms of ScopedGeneric. (https://codereview.chromium.org/191673003/) Reason for revert: Doesn't correctly link /mnt/data/b/build/slave/Chromium_Linux_Codesearch/build/src/third_party/gold/gold64: warning: hidden symbol 'base::internal::ScopedFDCloseTraits::Free(int)' in obj/base/files/nacl_helper.scoped_file.o is referenced by DSO lib/libipc.so Original issue's description: > Implement ScopedFD in terms of ScopedGeneric. > > Move to a new file base/files/scoped_file.h. I will also add ScopedFILE to here (currently in file_util.h) later. > > I think there is a crash in the old code in content/browser/zygote_host/zygote_host_impl_linux.cc that this patch should fix. The old ScopedFD took the address of something in a vector that is being modified. > > I removed SafeScopedFD from content/common/sandbox_linux/sandbox_linux.cc since base's ScopedFD not CHECKs on close failure (this is a more recent addition). > > BUG= > R=agl@chromium.org, viettrungluu@chromium.org > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=257001 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=257179 TBR=viettrungluu@chromium.org,agl@chromium.org,brettw@chromium.org NOTREECHECKS=true NOTRY=true BUG= Review URL: https://codereview.chromium.org/201203002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257323 0039d316-1c4b-4281-b951-d872f2087c98 --- net/test/spawned_test_server/local_test_server.h | 4 ++-- net/test/spawned_test_server/local_test_server_posix.cc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'net/test/spawned_test_server') diff --git a/net/test/spawned_test_server/local_test_server.h b/net/test/spawned_test_server/local_test_server.h index d916835..cfd2eb3 100644 --- a/net/test/spawned_test_server/local_test_server.h +++ b/net/test/spawned_test_server/local_test_server.h @@ -8,7 +8,6 @@ #include #include "base/file_util.h" -#include "base/files/scoped_file.h" #include "base/process/process_handle.h" #include "net/test/spawned_test_server/base_test_server.h" @@ -106,7 +105,8 @@ class LocalTestServer : public BaseTestServer { #if defined(OS_POSIX) // The file descriptor the child writes to when it starts. - base::ScopedFD child_fd_; + int child_fd_; + file_util::ScopedFD child_fd_closer_; #endif DISALLOW_COPY_AND_ASSIGN(LocalTestServer); diff --git a/net/test/spawned_test_server/local_test_server_posix.cc b/net/test/spawned_test_server/local_test_server_posix.cc index ea9cab6..10c2d0f 100644 --- a/net/test/spawned_test_server/local_test_server_posix.cc +++ b/net/test/spawned_test_server/local_test_server_posix.cc @@ -10,7 +10,6 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/process/kill.h" #include "base/process/launch.h" @@ -121,8 +120,9 @@ bool LocalTestServer::LaunchPython(const base::FilePath& testserver_path) { } // Save the read half. The write half is sent to the child. - child_fd_.reset(pipefd[0]); - base::ScopedFD write_closer(pipefd[1]); + child_fd_ = pipefd[0]; + child_fd_closer_.reset(&child_fd_); + file_util::ScopedFD write_closer(&pipefd[1]); base::FileHandleMappingVector map_write_fd; map_write_fd.push_back(std::make_pair(pipefd[1], pipefd[1])); @@ -148,19 +148,19 @@ bool LocalTestServer::LaunchPython(const base::FilePath& testserver_path) { } bool LocalTestServer::WaitToStart() { - base::ScopedFD our_fd(child_fd_.release()); + file_util::ScopedFD child_fd_closer(child_fd_closer_.release()); base::TimeDelta remaining_time = TestTimeouts::action_timeout(); uint32 server_data_len = 0; - if (!ReadData(our_fd.get(), sizeof(server_data_len), + if (!ReadData(child_fd_, sizeof(server_data_len), reinterpret_cast(&server_data_len), &remaining_time)) { LOG(ERROR) << "Could not read server_data_len"; return false; } std::string server_data(server_data_len, '\0'); - if (!ReadData(our_fd.get(), server_data_len, + if (!ReadData(child_fd_, server_data_len, reinterpret_cast(&server_data[0]), &remaining_time)) { LOG(ERROR) << "Could not read server_data (" << server_data_len -- cgit v1.1