| Index: runtime/bin/eventhandler_win.cc
|
| diff --git a/runtime/bin/eventhandler_win.cc b/runtime/bin/eventhandler_win.cc
|
| index 87706e83820b4d017fd2c2e1aa3dd08df94d9834..315027ef0b62657b0246e244b7bcd726caf77926 100644
|
| --- a/runtime/bin/eventhandler_win.cc
|
| +++ b/runtime/bin/eventhandler_win.cc
|
| @@ -261,12 +261,7 @@ bool Handle::IssueRead() {
|
| return true;
|
| }
|
| IOBuffer::DisposeBuffer(buffer);
|
| -
|
| - if (GetLastError() == ERROR_BROKEN_PIPE) {
|
| - event_handler_->HandleClosed(this);
|
| - } else {
|
| - event_handler_->HandleError(this);
|
| - }
|
| + HandleIssueError();
|
| return false;
|
| } else {
|
| // Completing asynchronously through thread.
|
| @@ -301,13 +296,19 @@ bool Handle::IssueWrite() {
|
| return true;
|
| }
|
| IOBuffer::DisposeBuffer(buffer);
|
| + HandleIssueError();
|
| + return false;
|
| +}
|
| +
|
|
|
| - if (GetLastError() == ERROR_BROKEN_PIPE) {
|
| +void Handle::HandleIssueError() {
|
| + DWORD error = GetLastError();
|
| + if (error == ERROR_BROKEN_PIPE) {
|
| event_handler_->HandleClosed(this);
|
| } else {
|
| event_handler_->HandleError(this);
|
| }
|
| - return false;
|
| + SetLastError(error);
|
| }
|
|
|
|
|
| @@ -329,6 +330,17 @@ void FileHandle::AfterClose() {
|
| }
|
|
|
|
|
| +void SocketHandle::HandleIssueError() {
|
| + int error = WSAGetLastError();
|
| + if (error == WSAECONNRESET) {
|
| + event_handler_->HandleClosed(this);
|
| + } else {
|
| + event_handler_->HandleError(this);
|
| + }
|
| + WSASetLastError(error);
|
| +}
|
| +
|
| +
|
| bool ListenSocket::LoadAcceptEx() {
|
| // Load the AcceptEx function into memory using WSAIoctl.
|
| // The WSAIoctl function is an extension of the ioctlsocket()
|
| @@ -518,8 +530,8 @@ int Handle::Write(const void* buffer, int num_bytes) {
|
| &bytes_written,
|
| NULL);
|
| if (!ok) {
|
| - if (GetLastError() != ERROR_BROKEN_PIPE) {
|
| - Log::PrintErr("WriteFile failed: %d\n", GetLastError());
|
| + if (GetLastError() != ERROR_BROKEN_PIPE) {
|
| + Log::PrintErr("WriteFile failed: %d\n", GetLastError());
|
| }
|
| event_handler_->HandleClosed(this);
|
| }
|
| @@ -564,12 +576,7 @@ bool ClientSocket::IssueRead() {
|
| }
|
| IOBuffer::DisposeBuffer(buffer);
|
| pending_read_ = NULL;
|
| -
|
| - if (WSAGetLastError() == WSAECONNRESET) {
|
| - event_handler_->HandleClosed(this);
|
| - } else {
|
| - event_handler_->HandleError(this);
|
| - }
|
| + HandleIssueError();
|
| return false;
|
| }
|
|
|
| @@ -592,12 +599,7 @@ bool ClientSocket::IssueWrite() {
|
| }
|
| IOBuffer::DisposeBuffer(pending_write_);
|
| pending_write_ = NULL;
|
| -
|
| - if (WSAGetLastError() == WSAECONNRESET) {
|
| - event_handler_->HandleClosed(this);
|
| - } else {
|
| - event_handler_->HandleError(this);
|
| - }
|
| + HandleIssueError();
|
| return false;
|
| }
|
|
|
|
|