diff options
| author | cdn@chromium.org <cdn@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-04-13 22:20:30 +0000 |
|---|---|---|
| committer | cdn@chromium.org <cdn@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-04-13 22:20:30 +0000 |
| commit | 9a3de4160b4808b89c367126027533323690915e (patch) | |
| tree | 96d42ce81be9754abd8d4a3cf3718ab36e7abc1c /src/client/windows/crash_generation | |
| parent | Fix file descriptor leaks in ExternalDumper test (diff) | |
| download | breakpad-9a3de4160b4808b89c367126027533323690915e.tar.xz | |
Expose a callback to allow crash server implementations to defer the uploading of crash dumps to a later time. The client can provide a crash_id when the dump is performed and then at a later time connect again and request that the crash id be uploaded triggering an implementation defined callback.
BUG=473
TEST=CrashGenerationServerTest.*
Review URL: https://breakpad.appspot.com/379001
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@952 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/windows/crash_generation')
5 files changed, 45 insertions, 10 deletions
diff --git a/src/client/windows/crash_generation/client_info.cc b/src/client/windows/crash_generation/client_info.cc index 94f9c3cd..9c51cda3 100644 --- a/src/client/windows/crash_generation/client_info.cc +++ b/src/client/windows/crash_generation/client_info.cc @@ -52,7 +52,8 @@ ClientInfo::ClientInfo(CrashGenerationServer* crash_server, dump_requested_handle_(NULL), dump_generated_handle_(NULL), dump_request_wait_handle_(NULL), - process_exit_wait_handle_(NULL) { + process_exit_wait_handle_(NULL), + crash_id_(NULL) { GetSystemTimeAsFileTime(&start_time_); } @@ -62,6 +63,12 @@ bool ClientInfo::Initialize() { return false; } + // The crash_id will be the low order word of the process creation time. + FILETIME creation_time, exit_time, kernel_time, user_time; + if (GetProcessTimes(process_handle_, &creation_time, &exit_time, + &kernel_time, &user_time)) + crash_id_ = creation_time.dwLowDateTime; + dump_requested_handle_ = CreateEvent(NULL, // Security attributes. TRUE, // Manual reset. FALSE, // Initial state. diff --git a/src/client/windows/crash_generation/client_info.h b/src/client/windows/crash_generation/client_info.h index 47a5d21f..999e6678 100644 --- a/src/client/windows/crash_generation/client_info.h +++ b/src/client/windows/crash_generation/client_info.h @@ -65,6 +65,7 @@ class ClientInfo { HANDLE process_handle() const { return process_handle_; } HANDLE dump_requested_handle() const { return dump_requested_handle_; } HANDLE dump_generated_handle() const { return dump_generated_handle_; } + DWORD crash_id() const { return crash_id_; } HANDLE dump_request_wait_handle() const { return dump_request_wait_handle_; @@ -160,6 +161,11 @@ class ClientInfo { // for the client process when it signals a crash. FILETIME start_time_; + // The crash id which can be used to request an upload. This will be the + // value of the low order dword of the process creation time for the process + // being dumped. + DWORD crash_id_; + // Disallow copy ctor and operator=. ClientInfo(const ClientInfo& client_info); ClientInfo& operator=(const ClientInfo& client_info); diff --git a/src/client/windows/crash_generation/crash_generation_client.cc b/src/client/windows/crash_generation/crash_generation_client.cc index 5e4e3cb9..749223f1 100644 --- a/src/client/windows/crash_generation/crash_generation_client.cc +++ b/src/client/windows/crash_generation/crash_generation_client.cc @@ -223,7 +223,7 @@ bool CrashGenerationClient::RegisterClient(HANDLE pipe) { crash_event_ = reply.dump_request_handle; crash_generated_ = reply.dump_generated_handle; server_alive_ = reply.server_alive_handle; - server_process_id_ = reply.pid; + server_process_id_ = reply.id; return true; } @@ -261,7 +261,7 @@ HANDLE CrashGenerationClient::ConnectToPipe(const wchar_t* pipe_name, bool CrashGenerationClient::ValidateResponse( const ProtocolMessage& msg) const { return (msg.tag == MESSAGE_TAG_REGISTRATION_RESPONSE) && - (msg.pid != 0) && + (msg.id != 0) && (msg.dump_request_handle != NULL) && (msg.dump_generated_handle != NULL) && (msg.server_alive_handle != NULL); diff --git a/src/client/windows/crash_generation/crash_generation_server.cc b/src/client/windows/crash_generation/crash_generation_server.cc index b180b2c2..d9769ae8 100644 --- a/src/client/windows/crash_generation/crash_generation_server.cc +++ b/src/client/windows/crash_generation/crash_generation_server.cc @@ -84,11 +84,12 @@ static const int kShutdownDelayMs = 10000; static const int kShutdownSleepIntervalMs = 5; static bool IsClientRequestValid(const ProtocolMessage& msg) { - return msg.tag == MESSAGE_TAG_REGISTRATION_REQUEST && - msg.pid != 0 && - msg.thread_id != NULL && - msg.exception_pointers != NULL && - msg.assert_info != NULL; + return msg.tag == MESSAGE_TAG_UPLOAD_REQUEST || + (msg.tag == MESSAGE_TAG_REGISTRATION_REQUEST && + msg.id != 0 && + msg.thread_id != NULL && + msg.exception_pointers != NULL && + msg.assert_info != NULL); } CrashGenerationServer::CrashGenerationServer( @@ -100,6 +101,8 @@ CrashGenerationServer::CrashGenerationServer( void* dump_context, OnClientExitedCallback exit_callback, void* exit_context, + OnClientUploadRequestCallback upload_request_callback, + void* upload_context, bool generate_dumps, const std::wstring* dump_path) : pipe_name_(pipe_name), @@ -113,6 +116,8 @@ CrashGenerationServer::CrashGenerationServer( dump_context_(dump_context), exit_callback_(exit_callback), exit_context_(exit_context), + upload_request_callback_(upload_request_callback), + upload_context_(upload_context), generate_dumps_(generate_dumps), dump_generator_(NULL), server_state_(IPC_SERVER_STATE_UNINITIALIZED), @@ -416,9 +421,15 @@ void CrashGenerationServer::HandleReadDoneState() { return; } + if (msg_.tag == MESSAGE_TAG_UPLOAD_REQUEST) { + if (upload_request_callback_) + upload_request_callback_(upload_context_, msg_.id); + return; + } + scoped_ptr<ClientInfo> client_info( new ClientInfo(this, - msg_.pid, + msg_.id, msg_.dump_type, msg_.thread_id, msg_.exception_pointers, @@ -582,7 +593,7 @@ void CrashGenerationServer::EnterStateImmediately(IPCServerState state) { bool CrashGenerationServer::PrepareReply(const ClientInfo& client_info, ProtocolMessage* reply) const { reply->tag = MESSAGE_TAG_REGISTRATION_RESPONSE; - reply->pid = GetCurrentProcessId(); + reply->id = GetCurrentProcessId(); if (CreateClientHandles(client_info, reply)) { return true; diff --git a/src/client/windows/crash_generation/crash_generation_server.h b/src/client/windows/crash_generation/crash_generation_server.h index 31a353bf..2f0a222c 100644 --- a/src/client/windows/crash_generation/crash_generation_server.h +++ b/src/client/windows/crash_generation/crash_generation_server.h @@ -59,6 +59,9 @@ class CrashGenerationServer { typedef void (*OnClientExitedCallback)(void* context, const ClientInfo* client_info); + typedef void (*OnClientUploadRequestCallback)(void* context, + const DWORD crash_id); + // Creates an instance with the given parameters. // // Parameter pipe_name: Name of the Windows named pipe @@ -86,6 +89,8 @@ class CrashGenerationServer { void* dump_context, OnClientExitedCallback exit_callback, void* exit_context, + OnClientUploadRequestCallback upload_request_callback, + void* upload_context, bool generate_dumps, const std::wstring* dump_path); @@ -250,6 +255,12 @@ class CrashGenerationServer { // Context for client process exit callback. void* exit_context_; + // Callback for upload request. + OnClientUploadRequestCallback upload_request_callback_; + + // Context for upload request callback. + void* upload_context_; + // Whether to generate dumps. bool generate_dumps_; |
