Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: runtime/bin/eventhandler_win.cc

Issue 12218035: Fix socket error reporting on Windows (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698