Index: base/sync_socket_win.cc |
diff --git a/base/sync_socket_win.cc b/base/sync_socket_win.cc |
index c6fb1ce789c4b7fe596f8cccd99e704ec1d0713c..41bea9fe44bb837c3aee14d251a36489394ea030 100644 |
--- a/base/sync_socket_win.cc |
+++ b/base/sync_socket_win.cc |
@@ -146,6 +146,11 @@ size_t CancelableFileOperation(Function operation, HANDLE file, |
return (0 < count) ? count : 0; |
} |
} |
+ |
+ // Quit the operation if we can't write/read anymore. |
+ if (len == 0) |
tommi (sloooow) - chröme
2012/04/13 10:28:10
do we actually hit this?
I would have thought that
no longer working on chromium
2012/04/13 11:50:50
Yes, when the buffer is full, the operation return
|
+ break; |
+ |
count += len; |
} |
return count; |
@@ -234,12 +239,28 @@ bool CancelableSyncSocket::Close() { |
} |
size_t CancelableSyncSocket::Send(const void* buffer, size_t length) { |
+ DWORD state = 0; |
+ if (GetNamedPipeHandleState(handle_, &state, NULL, NULL, NULL, NULL, 0)) { |
+ // Set the socket to non-blocking mode if it is blocking on sending. |
+ if ((state & PIPE_NOWAIT) == 0) { |
+ state = PIPE_NOWAIT; |
+ SetNamedPipeHandleState(handle_, &state, NULL, NULL); |
+ } |
+ } |
return CancelableFileOperation(&WriteFile, handle_, |
reinterpret_cast<const char*>(buffer), length, &file_operation_, |
&shutdown_event_, this); |
} |
size_t CancelableSyncSocket::Receive(void* buffer, size_t length) { |
+ DWORD state = 0; |
+ if (GetNamedPipeHandleState(handle_, &state, NULL, NULL, NULL, NULL, 0)) { |
tommi (sloooow) - chröme
2012/04/13 10:28:10
do this inside Send() after the file operation and
no longer working on chromium
2012/04/13 11:50:50
Done.
|
+ // Set the socket to blocking mode if it is non-blocking on receiving. |
+ if ((state & PIPE_WAIT) == 0) { |
+ state = PIPE_WAIT; |
+ SetNamedPipeHandleState(handle_, &state, NULL, NULL); |
+ } |
+ } |
return CancelableFileOperation(&ReadFile, handle_, |
reinterpret_cast<char*>(buffer), length, &file_operation_, |
&shutdown_event_, this); |