diff options
Diffstat (limited to 'src/client/windows/crash_generation')
-rw-r--r-- | src/client/windows/crash_generation/crash_generation_server.cc | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/client/windows/crash_generation/crash_generation_server.cc b/src/client/windows/crash_generation/crash_generation_server.cc index b98fb5e0..b4bb5c95 100644 --- a/src/client/windows/crash_generation/crash_generation_server.cc +++ b/src/client/windows/crash_generation/crash_generation_server.cc @@ -85,6 +85,15 @@ static bool IsClientRequestValid(const ProtocolMessage& msg) { msg.assert_info != NULL); } +#ifdef _DEBUG +static bool CheckForIOIncomplete(bool success) { + // We should never get an I/O incomplete since we should not execute this + // unless the operation has finished and the overlapped event is signaled. If + // we do get INCOMPLETE, we have a bug in our code. + return success ? false : (GetLastError() == ERROR_IO_INCOMPLETE); +} +#endif + CrashGenerationServer::CrashGenerationServer( const std::wstring& pipe_name, SECURITY_ATTRIBUTES* pipe_sec_attrs, @@ -388,18 +397,13 @@ void CrashGenerationServer::HandleReadingState() { &overlapped_, &bytes_count, FALSE) != FALSE; - DWORD error_code = success ? ERROR_SUCCESS : GetLastError(); - if (success && bytes_count == sizeof(ProtocolMessage)) { EnterStateImmediately(IPC_SERVER_STATE_READ_DONE); - } else { - // We should never get an I/O incomplete since we should not execute this - // unless the Read has finished and the overlapped event is signaled. If - // we do get INCOMPLETE, we have a bug in our code. - assert(error_code != ERROR_IO_INCOMPLETE); - - EnterStateImmediately(IPC_SERVER_STATE_DISCONNECTING); + return; } + + assert(!CheckForIOIncomplete(success)); + EnterStateImmediately(IPC_SERVER_STATE_DISCONNECTING); } // When the server thread serving the client is in the READ_DONE state, @@ -468,18 +472,12 @@ void CrashGenerationServer::HandleWritingState() { &overlapped_, &bytes_count, FALSE) != FALSE; - DWORD error_code = success ? ERROR_SUCCESS : GetLastError(); - if (success) { EnterStateImmediately(IPC_SERVER_STATE_WRITE_DONE); return; } - // We should never get an I/O incomplete since we should not execute this - // unless the Write has finished and the overlapped event is signaled. If - // we do get INCOMPLETE, we have a bug in our code. - assert(error_code != ERROR_IO_INCOMPLETE); - + assert(!CheckForIOIncomplete(success)); EnterStateImmediately(IPC_SERVER_STATE_DISCONNECTING); } @@ -517,8 +515,6 @@ void CrashGenerationServer::HandleReadingAckState() { &overlapped_, &bytes_count, FALSE) != FALSE; - DWORD error_code = success ? ERROR_SUCCESS : GetLastError(); - if (success) { // The connection handshake with the client is now complete; perform // the callback. @@ -551,10 +547,7 @@ void CrashGenerationServer::HandleReadingAckState() { } } } else { - // We should never get an I/O incomplete since we should not execute this - // unless the Read has finished and the overlapped event is signaled. If - // we do get INCOMPLETE, we have a bug in our code. - assert(error_code != ERROR_IO_INCOMPLETE); + assert(!CheckForIOIncomplete(success)); } EnterStateImmediately(IPC_SERVER_STATE_DISCONNECTING); |