| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 PCHECK(first_pipe_instance_.is_valid()) << "CreateNamedPipe"; | 341 PCHECK(first_pipe_instance_.is_valid()) << "CreateNamedPipe"; |
| 342 | 342 |
| 343 SetPipeName(pipe_name); | 343 SetPipeName(pipe_name); |
| 344 return pipe_name; | 344 return pipe_name; |
| 345 } | 345 } |
| 346 | 346 |
| 347 void ExceptionHandlerServer::Run(Delegate* delegate) { | 347 void ExceptionHandlerServer::Run(Delegate* delegate) { |
| 348 uint64_t shutdown_token = base::RandUint64(); | 348 uint64_t shutdown_token = base::RandUint64(); |
| 349 ScopedKernelHANDLE thread_handles[kPipeInstances]; | 349 ScopedKernelHANDLE thread_handles[kPipeInstances]; |
| 350 for (int i = 0; i < arraysize(thread_handles); ++i) { | 350 for (size_t i = 0; i < arraysize(thread_handles); ++i) { |
| 351 HANDLE pipe; | 351 HANDLE pipe; |
| 352 if (first_pipe_instance_.is_valid()) { | 352 if (first_pipe_instance_.is_valid()) { |
| 353 pipe = first_pipe_instance_.release(); | 353 pipe = first_pipe_instance_.release(); |
| 354 } else { | 354 } else { |
| 355 pipe = CreateNamedPipeInstance(pipe_name_, i == 0); | 355 pipe = CreateNamedPipeInstance(pipe_name_, i == 0); |
| 356 PCHECK(pipe != INVALID_HANDLE_VALUE) << "CreateNamedPipe"; | 356 PCHECK(pipe != INVALID_HANDLE_VALUE) << "CreateNamedPipe"; |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Ownership of this object (and the pipe instance) is given to the new | 359 // Ownership of this object (and the pipe instance) is given to the new |
| 360 // thread. We close the thread handles at the end of the scope. They clean | 360 // thread. We close the thread handles at the end of the scope. They clean |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // process handle can be signalled *before* the dump request is signalled. | 392 // process handle can be signalled *before* the dump request is signalled. |
| 393 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(key); | 393 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(key); |
| 394 base::AutoLock lock(clients_lock_); | 394 base::AutoLock lock(clients_lock_); |
| 395 clients_.erase(client); | 395 clients_.erase(client); |
| 396 delete client; | 396 delete client; |
| 397 if (!persistent_ && clients_.empty()) | 397 if (!persistent_ && clients_.empty()) |
| 398 break; | 398 break; |
| 399 } | 399 } |
| 400 | 400 |
| 401 // Signal to the named pipe instances that they should terminate. | 401 // Signal to the named pipe instances that they should terminate. |
| 402 for (int i = 0; i < arraysize(thread_handles); ++i) { | 402 for (size_t i = 0; i < arraysize(thread_handles); ++i) { |
| 403 ClientToServerMessage message; | 403 ClientToServerMessage message; |
| 404 memset(&message, 0, sizeof(message)); | 404 memset(&message, 0, sizeof(message)); |
| 405 message.type = ClientToServerMessage::kShutdown; | 405 message.type = ClientToServerMessage::kShutdown; |
| 406 message.shutdown.token = shutdown_token; | 406 message.shutdown.token = shutdown_token; |
| 407 ServerToClientMessage response; | 407 ServerToClientMessage response; |
| 408 SendToCrashHandlerServer(pipe_name_, | 408 SendToCrashHandlerServer(pipe_name_, |
| 409 reinterpret_cast<ClientToServerMessage&>(message), | 409 reinterpret_cast<ClientToServerMessage&>(message), |
| 410 &response); | 410 &response); |
| 411 } | 411 } |
| 412 | 412 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { | 593 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { |
| 594 // This function is executed on the thread pool. | 594 // This function is executed on the thread pool. |
| 595 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); | 595 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); |
| 596 base::AutoLock lock(*client->lock()); | 596 base::AutoLock lock(*client->lock()); |
| 597 | 597 |
| 598 // Post back to the main thread to have it delete this client record. | 598 // Post back to the main thread to have it delete this client record. |
| 599 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); | 599 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); |
| 600 } | 600 } |
| 601 | 601 |
| 602 } // namespace crashpad | 602 } // namespace crashpad |
| OLD | NEW |