From ee405c220b9c2551c6138c79375bf0f553cdb8c4 Mon Sep 17 00:00:00 2001 From: "yzshen@chromium.org" Date: Fri, 15 Jul 2011 19:18:51 +0000 Subject: Avoid leaking file handles. AsyncOpenFileCallback: fix the issue that file handle is leaked if the file handle arrives after the requester has died. This change also fixes test_file_system. BUG=79820 TEST=FileIO/FileRef/FileSystem tests in ppapi_tests: Reload the test page, the test still passes. The output files can be deleted when any of these tests finishes running, no matter the test page is still open or not. Review URL: http://codereview.chromium.org/7327025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92727 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/tests/test_file_system.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ppapi/tests/test_file_system.cc') diff --git a/ppapi/tests/test_file_system.cc b/ppapi/tests/test_file_system.cc index 9232385..cb37284 100644 --- a/ppapi/tests/test_file_system.cc +++ b/ppapi/tests/test_file_system.cc @@ -67,7 +67,9 @@ std::string TestFileSystem::TestMultipleOpens() { int32_t rv_2 = file_system.Open(1024, callback_2); if (force_async_ && rv_2 != PP_OK_COMPLETIONPENDING) return ReportError("FileSystem::Open2 force_async", rv_2); - if (rv_2 == PP_OK_COMPLETIONPENDING || rv_2 == PP_OK) + if (rv_2 == PP_OK_COMPLETIONPENDING) + rv_2 = callback_2.WaitForResult(); + if (rv_2 == PP_OK) return "FileSystem::Open2 should not allow multiple opens."; if (rv_1 == PP_OK_COMPLETIONPENDING) @@ -79,7 +81,9 @@ std::string TestFileSystem::TestMultipleOpens() { int32_t rv_3 = file_system.Open(1024, callback_3); if (force_async_ && rv_3 != PP_OK_COMPLETIONPENDING) return ReportError("FileSystem::Open3 force_async", rv_3); - if (rv_3 == PP_OK_COMPLETIONPENDING || rv_3 == PP_OK) + if (rv_3 == PP_OK_COMPLETIONPENDING) + rv_3 = callback_3.WaitForResult(); + if (rv_3 == PP_OK) return "FileSystem::Open3 should not allow multiple opens."; PASS(); -- cgit v1.1