summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 18:33:31 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 18:33:31 +0000
commita647bcf72f9b5b0120fee3b35e9facf57fface5a (patch)
treee8ce46aa8f2abc9eb42416b0462ba158bfbb44b9 /net
parent2544a7a0892dc6d3e0dd5c835e5dc7b286385bd3 (diff)
downloadchromium_src-a647bcf72f9b5b0120fee3b35e9facf57fface5a.zip
chromium_src-a647bcf72f9b5b0120fee3b35e9facf57fface5a.tar.gz
chromium_src-a647bcf72f9b5b0120fee3b35e9facf57fface5a.tar.bz2
Don't fire callbacks on Close(). Caller should take care of this already,
and this matches the way our tcp_client_socket works today. BUG=none TEST=none Review URL: http://codereview.chromium.org/6682023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78058 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/udp/udp_socket_libevent.cc15
-rw-r--r--net/udp/udp_socket_unittest.cc3
-rw-r--r--net/udp/udp_socket_win.cc9
3 files changed, 16 insertions, 11 deletions
diff --git a/net/udp/udp_socket_libevent.cc b/net/udp/udp_socket_libevent.cc
index de24253..15a149b96 100644
--- a/net/udp/udp_socket_libevent.cc
+++ b/net/udp/udp_socket_libevent.cc
@@ -103,14 +103,19 @@ UDPSocketLibevent::~UDPSocketLibevent() {
void UDPSocketLibevent::Close() {
DCHECK(CalledOnValidThread());
- if (read_callback_)
- DoReadCallback(ERR_ABORTED);
- if (write_callback_)
- DoReadCallback(ERR_ABORTED);
-
if (!is_connected())
return;
+ // Zero out any pending read/write callback state.
+ read_buf_ = NULL;
+ read_buf_len_ = 0;
+ read_callback_ = NULL;
+ recv_from_address_ = NULL;
+ write_buf_ = NULL;
+ write_buf_len_ = 0;
+ write_callback_ = NULL;
+ send_to_address_.reset();
+
bool ok = read_socket_watcher_.StopWatchingFileDescriptor();
DCHECK(ok);
ok = write_socket_watcher_.StopWatchingFileDescriptor();
diff --git a/net/udp/udp_socket_unittest.cc b/net/udp/udp_socket_unittest.cc
index 23caf22..1675f19 100644
--- a/net/udp/udp_socket_unittest.cc
+++ b/net/udp/udp_socket_unittest.cc
@@ -311,8 +311,7 @@ TEST_F(UDPSocketTest, CloseWithPendingRead) {
server.Close();
- EXPECT_TRUE(callback.have_result());
- EXPECT_EQ(callback.GetResult(rv), ERR_ABORTED);
+ EXPECT_FALSE(callback.have_result());
}
} // namespace
diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc
index 8a180d2..a7af53e 100644
--- a/net/udp/udp_socket_win.cc
+++ b/net/udp/udp_socket_win.cc
@@ -62,10 +62,11 @@ void UDPSocketWin::Close() {
if (!is_connected())
return;
- if (read_callback_)
- DoReadCallback(ERR_ABORTED);
- if (write_callback_)
- DoReadCallback(ERR_ABORTED);
+ // Zero out any pending read/write callback state.
+ read_callback_ = NULL;
+ recv_from_address_ = NULL;
+ write_callback_ = NULL;
+ send_to_address_.reset();
read_watcher_.StopWatching();
write_watcher_.StopWatching();