Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: ppapi/tests/test_broker.cc

Issue 8591008: Add EINTR handling on ::close() calls in ppapi broker ui test. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/tests/test_broker.h" 5 #include "ppapi/tests/test_broker.h"
6 6
7 #if defined(_MSC_VER) 7 #if defined(_MSC_VER)
8 #define OS_WIN 1 8 #define OS_WIN 1
9 #include <windows.h> 9 #include <windows.h>
10 #else 10 #else
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 bool success = ReadMessage(file, message_len, message_received) && 113 bool success = ReadMessage(file, message_len, message_received) &&
114 !::strcmp(message_received, message); 114 !::strcmp(message_received, message);
115 delete [] message_received; 115 delete [] message_received;
116 return success; 116 return success;
117 } 117 }
118 118
119 bool ClosePlatformFile(PlatformFile file) { 119 bool ClosePlatformFile(PlatformFile file) {
120 #if defined(OS_WIN) 120 #if defined(OS_WIN)
121 return !!::CloseHandle(file); 121 return !!::CloseHandle(file);
122 #elif defined(OS_POSIX) 122 #elif defined(OS_POSIX)
123 return !::close(file); 123 return !HANDLE_EINTR(::close(file));
124 #endif 124 #endif
125 } 125 }
126 126
127 bool VerifyIsUnsandboxed() { 127 bool VerifyIsUnsandboxed() {
128 #if defined(OS_WIN) 128 #if defined(OS_WIN)
129 FILE* file = NULL; 129 FILE* file = NULL;
130 wchar_t temp_path[MAX_PATH] = {'\0'}; 130 wchar_t temp_path[MAX_PATH] = {'\0'};
131 wchar_t file_name[MAX_PATH] = {'\0'}; 131 wchar_t file_name[MAX_PATH] = {'\0'};
132 if (!::GetTempPath(MAX_PATH, temp_path) || 132 if (!::GetTempPath(MAX_PATH, temp_path) ||
133 !::GetTempFileName(temp_path, L"test_pepper_broker", 0, file_name) || 133 !::GetTempFileName(temp_path, L"test_pepper_broker", 0, file_name) ||
134 ::_wfopen_s(&file, file_name, L"w")) 134 ::_wfopen_s(&file, file_name, L"w"))
135 return false; 135 return false;
136 136
137 if (::fclose(file)) { 137 if (::fclose(file)) {
138 ::DeleteFile(file_name); 138 ::DeleteFile(file_name);
139 return false; 139 return false;
140 } 140 }
141 141
142 return !!::DeleteFile(file_name); 142 return !!::DeleteFile(file_name);
143 #elif defined(OS_POSIX) 143 #elif defined(OS_POSIX)
144 char file_name[] = "/tmp/test_pepper_broker_XXXXXX"; 144 char file_name[] = "/tmp/test_pepper_broker_XXXXXX";
145 int fd = ::mkstemp(file_name); 145 int fd = ::mkstemp(file_name);
xhwang 2011/11/17 01:25:16 I saw examples of using HANDLE_EINTR for mkstemp()
ddorwin 2011/11/21 22:41:14 Maybe double check on Ubuntu's man page. I concur
xhwang 2011/11/21 23:15:16 Checked man page of Ubuntu and mkstemp doesn't tri
piman 2011/11/21 23:23:45 Usually, libc functions deal internally with the r
146 if (-1 == fd) 146 if (-1 == fd)
147 return false; 147 return false;
148 148
149 if (::close(fd)) { 149 if (HANDLE_EINTR(::close(fd))) {
150 ::remove(file_name); 150 ::remove(file_name);
151 return false; 151 return false;
152 } 152 }
153 153
154 return !::remove(file_name); 154 return !::remove(file_name);
155 #endif 155 #endif
156 } 156 }
157 157
158 // Callback in the broker when a new broker connection occurs. 158 // Callback in the broker when a new broker connection occurs.
159 int32_t OnInstanceConnected(PP_Instance instance, int32_t handle) { 159 int32_t OnInstanceConnected(PP_Instance instance, int32_t handle) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 PlatformFile file = IntToPlatformFile(handle); 282 PlatformFile file = IntToPlatformFile(handle);
283 ASSERT_TRUE(VerifyMessage(file, sizeof(kHelloMessage), kHelloMessage)); 283 ASSERT_TRUE(VerifyMessage(file, sizeof(kHelloMessage), kHelloMessage));
284 ASSERT_TRUE(VerifyMessage(file, sizeof(kBrokerUnsandboxed), 284 ASSERT_TRUE(VerifyMessage(file, sizeof(kBrokerUnsandboxed),
285 kBrokerUnsandboxed)); 285 kBrokerUnsandboxed));
286 286
287 ASSERT_TRUE(ClosePlatformFile(file)); 287 ASSERT_TRUE(ClosePlatformFile(file));
288 288
289 PASS(); 289 PASS();
290 } 290 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698