fix issue when tcp is closed

This commit is contained in:
Emiel Bruijntjes 2015-11-04 13:05:03 +01:00
parent c2c62562e7
commit dcf0b3576b
1 changed files with 9 additions and 2 deletions

View File

@ -125,14 +125,21 @@ public:
} }
else else
{ {
// we need a local copy of the buffer - because it is possible that "this"
// object gets destructed halfway through the call to the parse() method
TcpBuffer buffer(std::move(_in));
// parse the buffer // parse the buffer
auto processed = _connection->parse(_in); auto processed = _connection->parse(buffer);
// "this" could be removed by now, check this // "this" could be removed by now, check this
if (!monitor.valid()) return nullptr; if (!monitor.valid()) return nullptr;
// shrink buffer // shrink buffer
_in.shrink(processed); buffer.shrink(processed);
// restore the buffer as member
_in.swap(buffer);
} }
} }