| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 WinVMAddress debug_critical_section_address_; | 227 WinVMAddress debug_critical_section_address_; |
| 228 | 228 |
| 229 DISALLOW_COPY_AND_ASSIGN(ClientData); | 229 DISALLOW_COPY_AND_ASSIGN(ClientData); |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 } // namespace internal | 232 } // namespace internal |
| 233 | 233 |
| 234 ExceptionHandlerServer::Delegate::~Delegate() { | 234 ExceptionHandlerServer::Delegate::~Delegate() { |
| 235 } | 235 } |
| 236 | 236 |
| 237 ExceptionHandlerServer::ExceptionHandlerServer(const std::string& pipe_name) | 237 ExceptionHandlerServer::ExceptionHandlerServer() |
| 238 : pipe_name_(pipe_name), | 238 : port_(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 1)), |
| 239 port_(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 1)), | |
| 240 clients_lock_(), | 239 clients_lock_(), |
| 241 clients_() { | 240 clients_() { |
| 242 } | 241 } |
| 243 | 242 |
| 244 ExceptionHandlerServer::~ExceptionHandlerServer() { | 243 ExceptionHandlerServer::~ExceptionHandlerServer() { |
| 245 } | 244 } |
| 246 | 245 |
| 247 void ExceptionHandlerServer::Run(Delegate* delegate) { | 246 void ExceptionHandlerServer::Run(Delegate* delegate, |
| 247 const std::string& pipe_name) { |
| 248 uint64_t shutdown_token = base::RandUint64(); | 248 uint64_t shutdown_token = base::RandUint64(); |
| 249 // We create two pipe instances, so that there's one listening while the | 249 // We create two pipe instances, so that there's one listening while the |
| 250 // PipeServiceProc is processing a registration. | 250 // PipeServiceProc is processing a registration. |
| 251 ScopedKernelHANDLE thread_handles[2]; | 251 ScopedKernelHANDLE thread_handles[2]; |
| 252 base::string16 pipe_name_16(base::UTF8ToUTF16(pipe_name_)); | 252 base::string16 pipe_name_16(base::UTF8ToUTF16(pipe_name)); |
| 253 for (int i = 0; i < arraysize(thread_handles); ++i) { | 253 for (int i = 0; i < arraysize(thread_handles); ++i) { |
| 254 HANDLE pipe = | 254 HANDLE pipe = |
| 255 CreateNamedPipe(pipe_name_16.c_str(), | 255 CreateNamedPipe(pipe_name_16.c_str(), |
| 256 PIPE_ACCESS_DUPLEX, | 256 PIPE_ACCESS_DUPLEX, |
| 257 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, | 257 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, |
| 258 arraysize(thread_handles), | 258 arraysize(thread_handles), |
| 259 512, | 259 512, |
| 260 512, | 260 512, |
| 261 0, | 261 0, |
| 262 nullptr); | 262 nullptr); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 delete client; | 304 delete client; |
| 305 } | 305 } |
| 306 | 306 |
| 307 // Signal to the named pipe instances that they should terminate. | 307 // Signal to the named pipe instances that they should terminate. |
| 308 for (int i = 0; i < arraysize(thread_handles); ++i) { | 308 for (int i = 0; i < arraysize(thread_handles); ++i) { |
| 309 ClientToServerMessage message; | 309 ClientToServerMessage message; |
| 310 memset(&message, 0, sizeof(message)); | 310 memset(&message, 0, sizeof(message)); |
| 311 message.type = ClientToServerMessage::kShutdown; | 311 message.type = ClientToServerMessage::kShutdown; |
| 312 message.shutdown.token = shutdown_token; | 312 message.shutdown.token = shutdown_token; |
| 313 ServerToClientMessage response; | 313 ServerToClientMessage response; |
| 314 SendToCrashHandlerServer(pipe_name_16, | 314 SendToCrashHandlerServer(base::UTF8ToUTF16(pipe_name), |
| 315 reinterpret_cast<ClientToServerMessage&>(message), | 315 reinterpret_cast<ClientToServerMessage&>(message), |
| 316 &response); | 316 &response); |
| 317 } | 317 } |
| 318 | 318 |
| 319 for (auto& handle : thread_handles) | 319 for (auto& handle : thread_handles) |
| 320 WaitForSingleObject(handle.get(), INFINITE); | 320 WaitForSingleObject(handle.get(), INFINITE); |
| 321 | 321 |
| 322 // Deleting ClientData does a blocking wait until the threadpool executions | 322 // Deleting ClientData does a blocking wait until the threadpool executions |
| 323 // have terminated when unregistering them. | 323 // have terminated when unregistering them. |
| 324 { | 324 { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { | 499 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { |
| 500 // This function is executed on the thread pool. | 500 // This function is executed on the thread pool. |
| 501 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); | 501 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); |
| 502 base::AutoLock lock(*client->lock()); | 502 base::AutoLock lock(*client->lock()); |
| 503 | 503 |
| 504 // Post back to the main thread to have it delete this client record. | 504 // Post back to the main thread to have it delete this client record. |
| 505 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); | 505 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); |
| 506 } | 506 } |
| 507 | 507 |
| 508 } // namespace crashpad | 508 } // namespace crashpad |
| OLD | NEW |