summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-14 22:55:04 +0000
committerwtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-14 22:55:04 +0000
commit5656af67903d044c131bc07ebf41e0fc20bf1f29 (patch)
treee3b529668d0f61ef39b79a2d9aa6aa59d8eab182 /net
parenteddf4cac5afd0e56f3a50ae854eaf334285ea98e (diff)
downloadchromium_src-5656af67903d044c131bc07ebf41e0fc20bf1f29.zip
chromium_src-5656af67903d044c131bc07ebf41e0fc20bf1f29.tar.gz
chromium_src-5656af67903d044c131bc07ebf41e0fc20bf1f29.tar.bz2
Update the comment for OnObjectSignaled.
The event object for the completion of overlapped I/O is also set when WSARecv or WSASend returns 0, so we need to reset the event object in that case. Add temporary debugging code to assert that the event object is in the expected state before and after WSARecv and WSASend calls. R=darin git-svn-id: svn://svn.chromium.org/chrome/trunk/src@906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/tcp_client_socket.cc26
-rw-r--r--net/base/tcp_client_socket.h2
2 files changed, 21 insertions, 7 deletions
diff --git a/net/base/tcp_client_socket.cc b/net/base/tcp_client_socket.cc
index cef7ef2..e2a4a2a 100644
--- a/net/base/tcp_client_socket.cc
+++ b/net/base/tcp_client_socket.cc
@@ -175,17 +175,24 @@ int TCPClientSocket::Read(char* buf,
buffer_.len = buf_len;
buffer_.buf = buf;
+ // TODO(wtc): Remove the CHECKs after enough testing.
+ CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT);
DWORD num, flags = 0;
int rv = WSARecv(socket_, &buffer_, 1, &num, &flags, &overlapped_, NULL);
- if (rv == 0)
+ if (rv == 0) {
+ CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_OBJECT_0);
+ BOOL ok = WSAResetEvent(overlapped_.hEvent);
+ CHECK(ok);
return static_cast<int>(num);
- if (rv == SOCKET_ERROR && WSAGetLastError() == WSA_IO_PENDING) {
+ }
+ int err = WSAGetLastError();
+ if (err == WSA_IO_PENDING) {
watcher_.StartWatching(overlapped_.hEvent, this);
wait_state_ = WAITING_READ;
callback_ = callback;
return ERR_IO_PENDING;
}
- return MapWinsockError(WSAGetLastError());
+ return MapWinsockError(err);
}
int TCPClientSocket::Write(const char* buf,
@@ -198,17 +205,24 @@ int TCPClientSocket::Write(const char* buf,
buffer_.len = buf_len;
buffer_.buf = const_cast<char*>(buf);
+ // TODO(wtc): Remove the CHECKs after enough testing.
+ CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT);
DWORD num;
int rv = WSASend(socket_, &buffer_, 1, &num, 0, &overlapped_, NULL);
- if (rv == 0)
+ if (rv == 0) {
+ CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_OBJECT_0);
+ BOOL ok = WSAResetEvent(overlapped_.hEvent);
+ CHECK(ok);
return static_cast<int>(num);
- if (rv == SOCKET_ERROR && WSAGetLastError() == WSA_IO_PENDING) {
+ }
+ int err = WSAGetLastError();
+ if (err == WSA_IO_PENDING) {
watcher_.StartWatching(overlapped_.hEvent, this);
wait_state_ = WAITING_WRITE;
callback_ = callback;
return ERR_IO_PENDING;
}
- return MapWinsockError(WSAGetLastError());
+ return MapWinsockError(err);
}
int TCPClientSocket::CreateSocket(const struct addrinfo* ai) {
diff --git a/net/base/tcp_client_socket.h b/net/base/tcp_client_socket.h
index 3885026..57960c9 100644
--- a/net/base/tcp_client_socket.h
+++ b/net/base/tcp_client_socket.h
@@ -68,7 +68,7 @@ class TCPClientSocket : public ClientSocket,
void DidCompleteConnect();
void DidCompleteIO();
- // MessageLoop::Watcher methods:
+ // base::ObjectWatcher::Delegate methods:
virtual void OnObjectSignaled(HANDLE object);
SOCKET socket_;