File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -168,18 +168,15 @@ void TcpServer::handleCloseInLoop(const TcpConnectionPtr &connectionPtr)
168
168
(void )n;
169
169
assert (n == 1 );
170
170
auto connLoop = connectionPtr->getLoop ();
171
- if (connLoop == loop_)
172
- {
171
+
172
+ // NOTE: always queue this operation in connLoop, because this connection
173
+ // may be in loop_'s current active channels, waiting to be processed.
174
+ // If `connectDestroyed()` is called here, we will be using an wild pointer
175
+ // later.
176
+ connLoop->queueInLoop ([connectionPtr]() {
173
177
static_cast <TcpConnectionImpl *>(connectionPtr.get ())
174
178
->connectDestroyed ();
175
- }
176
- else
177
- {
178
- connLoop->queueInLoop ([connectionPtr]() {
179
- static_cast <TcpConnectionImpl *>(connectionPtr.get ())
180
- ->connectDestroyed ();
181
- });
182
- }
179
+ });
183
180
}
184
181
void TcpServer::connectionClosed (const TcpConnectionPtr &connectionPtr)
185
182
{
You can’t perform that action at this time.
0 commit comments