Allow unregistering connect callback in AsyncSocket
authorViswanath Sivakumar <viswanath@fb.com>
Tue, 23 Dec 2014 20:16:48 +0000 (12:16 -0800)
committerDave Watson <davejwatson@fb.com>
Mon, 29 Dec 2014 18:40:21 +0000 (10:40 -0800)
commit98a687df16ba7f9c09730d1260a9a33dc5ccb329
tree0edc116dfc1412550017380344363a39f60e6d5f
parentb61dfbebfb3c125bc5b7e4cc235ab2ea8bfb5086
Allow unregistering connect callback in AsyncSocket

Summary:
Sometimes when the socket is destroyed from a destructor, we wouldn't
want further callbacks on shutdown. We can unregister the readCallback_
by calling setReadCB(nullptr), but if the state is CONNECTING, we can
still get connectErr() callback. I found an ASAN trace (https://phabricator.fb.com/P18837265)
that turned out to be because of this inability to cancel this callback.
This provides a way to unregister the connect callback as well.

Test Plan: fbconfig -r folly && fbmake runtests

Reviewed By: afrind@fb.com

Subscribers: folly-diffs@

FB internal diff: D1751778

Tasks: 5852935

Signature: t1:1751778:1419363638:26967c2d4fc5819e4d65ae706d217a954dfd784f
folly/io/async/AsyncSocket.cpp
folly/io/async/AsyncSocket.h