commit
a3a6a27efc
|
|
@ -70,13 +70,16 @@ void TcpConnection::process(int fd, int flags)
|
||||||
auto *result = _state->process(monitor, fd, flags);
|
auto *result = _state->process(monitor, fd, flags);
|
||||||
|
|
||||||
// are we still valid
|
// are we still valid
|
||||||
if (!monitor.valid()) return;
|
if (!monitor.valid() && result != _state.get())
|
||||||
|
{
|
||||||
|
delete result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// skip if the same state is continued to be used, or when the process()
|
// skip if the same state is continued to be used, or when the process()
|
||||||
// method returns nullptr (which only happens when the object is destructed,
|
// method returns nullptr (which only happens when the object is destructed,
|
||||||
// and "this" is no longer valid)
|
// and "this" is no longer valid)
|
||||||
if (!result || result == _state.get()) return;
|
if (!result || result == _state.get()) return;
|
||||||
|
|
||||||
// replace it with the new implementation
|
// replace it with the new implementation
|
||||||
_state.reset(result);
|
_state.reset(result);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue