Skip to content

Commit

Permalink
Run pending connect and accept callbacks immediately when socket disc…
Browse files Browse the repository at this point in the history
…onnected.

Solve DCHECK erorr in ~UIThreadExtensionFunction where
SocketsTcpConnectFunction is destructed before any responses were made.
  • Loading branch information
yrliou committed Aug 27, 2018
1 parent 7f205a0 commit 360746b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions patches/extensions-browser-api-socket-tcp_socket.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/extensions/browser/api/socket/tcp_socket.cc b/extensions/browser/api/socket/tcp_socket.cc
index e80bd7718bee608d4805d8d5ff63642296f20335..d0661a666757d0440b636e0177454e41675abbf6 100644
--- a/extensions/browser/api/socket/tcp_socket.cc
+++ b/extensions/browser/api/socket/tcp_socket.cc
@@ -149,8 +149,16 @@ void TCPSocket::Disconnect(bool socket_destroying) {
client_socket_.reset();
server_socket_.reset();
listen_callback_.Reset();
- connect_callback_.Reset();
- accept_callback_.Reset();
+ if (connect_callback_) {
+ std::move(connect_callback_)
+ .Run(net::ERR_CONNECTION_CLOSED);
+ }
+ if (accept_callback_) {
+ std::move(accept_callback_)
+ .Run(net::ERR_CONNECTION_CLOSED, nullptr, base::nullopt,
+ mojo::ScopedDataPipeConsumerHandle(),
+ mojo::ScopedDataPipeProducerHandle());
+ }
// TODO(devlin): Should we do this for all callbacks?
if (read_callback_) {
std::move(read_callback_)

0 comments on commit 360746b

Please sign in to comment.