| 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(const std::string& pipe_name, |
| 238 bool persistent) |
| 238 : pipe_name_(pipe_name), | 239 : pipe_name_(pipe_name), |
| 239 port_(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 1)), | 240 port_(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 1)), |
| 240 clients_lock_(), | 241 clients_lock_(), |
| 241 clients_() { | 242 clients_(), |
| 243 persistent_(persistent) { |
| 242 } | 244 } |
| 243 | 245 |
| 244 ExceptionHandlerServer::~ExceptionHandlerServer() { | 246 ExceptionHandlerServer::~ExceptionHandlerServer() { |
| 245 } | 247 } |
| 246 | 248 |
| 247 void ExceptionHandlerServer::Run(Delegate* delegate) { | 249 void ExceptionHandlerServer::Run(Delegate* delegate) { |
| 248 uint64_t shutdown_token = base::RandUint64(); | 250 uint64_t shutdown_token = base::RandUint64(); |
| 249 // We create two pipe instances, so that there's one listening while the | 251 // We create two pipe instances, so that there's one listening while the |
| 250 // PipeServiceProc is processing a registration. | 252 // PipeServiceProc is processing a registration. |
| 251 ScopedKernelHANDLE thread_handles[2]; | 253 ScopedKernelHANDLE thread_handles[2]; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (!key) { | 292 if (!key) { |
| 291 // Shutting down. | 293 // Shutting down. |
| 292 break; | 294 break; |
| 293 } | 295 } |
| 294 | 296 |
| 295 // Otherwise, this is a request to unregister and destroy the given client. | 297 // Otherwise, this is a request to unregister and destroy the given client. |
| 296 // delete'ing the ClientData blocks in UnregisterWaitEx to ensure all | 298 // delete'ing the ClientData blocks in UnregisterWaitEx to ensure all |
| 297 // outstanding threadpool waits are complete. This is important because the | 299 // outstanding threadpool waits are complete. This is important because the |
| 298 // process handle can be signalled *before* the dump request is signalled. | 300 // process handle can be signalled *before* the dump request is signalled. |
| 299 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(key); | 301 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(key); |
| 300 { | 302 base::AutoLock lock(clients_lock_); |
| 301 base::AutoLock lock(clients_lock_); | 303 clients_.erase(client); |
| 302 clients_.erase(client); | |
| 303 } | |
| 304 delete client; | 304 delete client; |
| 305 if (!persistent_ && clients_.empty()) |
| 306 break; |
| 305 } | 307 } |
| 306 | 308 |
| 307 // Signal to the named pipe instances that they should terminate. | 309 // Signal to the named pipe instances that they should terminate. |
| 308 for (int i = 0; i < arraysize(thread_handles); ++i) { | 310 for (int i = 0; i < arraysize(thread_handles); ++i) { |
| 309 ClientToServerMessage message; | 311 ClientToServerMessage message; |
| 310 memset(&message, 0, sizeof(message)); | 312 memset(&message, 0, sizeof(message)); |
| 311 message.type = ClientToServerMessage::kShutdown; | 313 message.type = ClientToServerMessage::kShutdown; |
| 312 message.shutdown.token = shutdown_token; | 314 message.shutdown.token = shutdown_token; |
| 313 ServerToClientMessage response; | 315 ServerToClientMessage response; |
| 314 SendToCrashHandlerServer(pipe_name_16, | 316 SendToCrashHandlerServer(pipe_name_16, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { | 501 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { |
| 500 // This function is executed on the thread pool. | 502 // This function is executed on the thread pool. |
| 501 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); | 503 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); |
| 502 base::AutoLock lock(*client->lock()); | 504 base::AutoLock lock(*client->lock()); |
| 503 | 505 |
| 504 // Post back to the main thread to have it delete this client record. | 506 // Post back to the main thread to have it delete this client record. |
| 505 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); | 507 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); |
| 506 } | 508 } |
| 507 | 509 |
| 508 } // namespace crashpad | 510 } // namespace crashpad |
| OLD | NEW |