| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 for (int i = 0; i < arraysize(thread_handles); ++i) { | 204 for (int i = 0; i < arraysize(thread_handles); ++i) { |
| 205 HANDLE pipe = | 205 HANDLE pipe = |
| 206 CreateNamedPipe(pipe_name_16.c_str(), | 206 CreateNamedPipe(pipe_name_16.c_str(), |
| 207 PIPE_ACCESS_DUPLEX, | 207 PIPE_ACCESS_DUPLEX, |
| 208 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, | 208 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, |
| 209 arraysize(thread_handles), | 209 arraysize(thread_handles), |
| 210 512, | 210 512, |
| 211 512, | 211 512, |
| 212 0, | 212 0, |
| 213 nullptr); | 213 nullptr); |
| 214 PCHECK(pipe != INVALID_HANDLE_VALUE) << "CreateNamedPipe"; |
| 214 | 215 |
| 215 // Ownership of this object (and the pipe instance) is given to the new | 216 // Ownership of this object (and the pipe instance) is given to the new |
| 216 // thread. We close the thread handles at the end of the scope. They clean | 217 // thread. We close the thread handles at the end of the scope. They clean |
| 217 // up the context object and the pipe instance on termination. | 218 // up the context object and the pipe instance on termination. |
| 218 internal::PipeServiceContext* context = | 219 internal::PipeServiceContext* context = |
| 219 new internal::PipeServiceContext(port_.get(), | 220 new internal::PipeServiceContext(port_.get(), |
| 220 pipe, | 221 pipe, |
| 221 delegate, | 222 delegate, |
| 222 &clients_lock_, | 223 &clients_lock_, |
| 223 &clients_, | 224 &clients_, |
| 224 shutdown_token); | 225 shutdown_token); |
| 225 thread_handles[i].reset( | 226 thread_handles[i].reset( |
| 226 CreateThread(nullptr, 0, &PipeServiceProc, context, 0, nullptr)); | 227 CreateThread(nullptr, 0, &PipeServiceProc, context, 0, nullptr)); |
| 228 PCHECK(thread_handles[i].is_valid()) << "CreateThread"; |
| 227 } | 229 } |
| 228 | 230 |
| 229 delegate->ExceptionHandlerServerStarted(); | 231 delegate->ExceptionHandlerServerStarted(); |
| 230 | 232 |
| 231 // This is the main loop of the server. Most work is done on the threadpool, | 233 // This is the main loop of the server. Most work is done on the threadpool, |
| 232 // other than process end handling which is posted back to this main thread, | 234 // other than process end handling which is posted back to this main thread, |
| 233 // as we must unregister the threadpool waits here. | 235 // as we must unregister the threadpool waits here. |
| 234 for (;;) { | 236 for (;;) { |
| 235 OVERLAPPED* ov = nullptr; | 237 OVERLAPPED* ov = nullptr; |
| 236 ULONG_PTR key = 0; | 238 ULONG_PTR key = 0; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { | 422 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { |
| 421 // This function is executed on the thread pool. | 423 // This function is executed on the thread pool. |
| 422 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); | 424 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); |
| 423 base::AutoLock lock(*client->lock()); | 425 base::AutoLock lock(*client->lock()); |
| 424 | 426 |
| 425 // Post back to the main thread to have it delete this client record. | 427 // Post back to the main thread to have it delete this client record. |
| 426 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); | 428 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); |
| 427 } | 429 } |
| 428 | 430 |
| 429 } // namespace crashpad | 431 } // namespace crashpad |
| OLD | NEW |