summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
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();