Set bufferCallback_ back to nullptr upon HTTPSession shutdown
authorYang Chi <yangchi@fb.com>
Fri, 27 May 2016 22:33:40 +0000 (15:33 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Fri, 27 May 2016 22:38:35 +0000 (15:38 -0700)
commit5451eeae6eff35f3b839d532d4939bd587b15ba5
tree21a7c9f833564825ee6da96113ebf793343d0b74
parent8eaa9657503eb2a7b58293111d2ec3c52c9a8942
Set bufferCallback_ back to nullptr upon HTTPSession shutdown

Summary: AsyncSocket::handleWrite may trigger HTTPSession::onWriteSuccess which may totally delete the HTTPSession. AsyncSocket::handleWrite also calls bufferCallback_->onEgressBufferCleared(). That bufferCallback_ is the HTTPSession. So in this diff resets bufferCallback_ to nullptr upon HTTPSession shutdown. afrind had a suggestion of adding a DestructorGuard in AsyncSocket::handleWrite. But i don't know DestructorGuard that well. I think it will keep AsyncSocket from being deleted but not the HTTPSession? Or maybe I can DestructorGuard dg(bufferCallback_) ?

Reviewed By: afrind

Differential Revision: D3311058

fbshipit-source-id: cdb5fcbd53837a3effbc096eab87fca4e5d17291
folly/io/async/AsyncSocket.cpp
folly/io/async/test/AsyncSocketTest2.cpp