MCPcopy Create free account
hub / github.com/Snapchat/Valdi / close

Method close

valdi/src/valdi/runtime/Debugger/TCPConnectionImpl.cpp:89–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void TCPConnectionImpl::close(const Error& error) {
90 Shared<ITCPConnectionDisconnectListener> listener;
91
92 {
93 std::lock_guard<Mutex> guard(_mutex);
94
95 if (_closed) {
96 return;
97 }
98
99 _closed = true;
100
101 if (_socket.is_open()) {
102 boost::system::error_code ec;
103 _socket.shutdown(boost::asio::ip::tcp::socket::shutdown_send, ec);
104 _socket.close(ec);
105 }
106
107 listener = _disconnectListener;
108 }
109
110 // Call listener outside the lock to avoid potential deadlocks
111 if (listener != nullptr) {
112 listener->onDisconnected(strongSmallRef(this), error);
113 }
114}
115
116void TCPConnectionImpl::setDataListener(Shared<ITCPConnectionDataListener> listener) {
117 std::lock_guard<Mutex> guard(_mutex);

Callers

nothing calls this directly

Calls 3

strongSmallRefFunction · 0.85
closeMethod · 0.65
onDisconnectedMethod · 0.45

Tested by

no test coverage detected