Commit ed0d101c authored by Jun Li (Wormhole)'s avatar Jun Li (Wormhole) Committed by Facebook Github Bot

Cancel immediate read callback when socket has error

Summary:
When `startFail()` is called, it sets the state to StateEnum::ERROR.
There is a chance that immediate read callback is scheduled to run in
next event loop. The callback calls handleRead() then triggers
`assert(state_ == StateEnum::ESTABLISHED)` in `AsyncSokcet::handleRead`.

Cancel any immediate read callback when startFail is called.

Reviewed By: yfeldblum

Differential Revision: D7051956

fbshipit-source-id: 0d6693d851b272355a4f36ab8d001969fa47750e
parent f6ca0ac0
...@@ -2473,6 +2473,11 @@ void AsyncSocket::startFail() { ...@@ -2473,6 +2473,11 @@ void AsyncSocket::startFail() {
// so all future attempts to read or write will be rejected // so all future attempts to read or write will be rejected
shutdownFlags_ |= (SHUT_READ | SHUT_WRITE); shutdownFlags_ |= (SHUT_READ | SHUT_WRITE);
// Cancel any scheduled immediate read.
if (immediateReadHandler_.isLoopCallbackScheduled()) {
immediateReadHandler_.cancelLoopCallback();
}
if (eventFlags_ != EventHandler::NONE) { if (eventFlags_ != EventHandler::NONE) {
eventFlags_ = EventHandler::NONE; eventFlags_ = EventHandler::NONE;
ioHandler_.unregisterHandler(); ioHandler_.unregisterHandler();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment