Refactor key agreement connection choosing
This branch fixes two bugs in the key agreement connection code that can cause connections not to be closed:
- If we receive an incoming connection and then cancel the exchange before scanning the other party's QR code, the connection is never closed (we loop in
ReadableTask#call()
waiting foralice
to become true or data to become available). - If an outgoing connection attempt is in progress when
closePending()
is called, and the attempt subsequently succeeds, the connection is never closed (the Future's value can't be retrieved because it's been cancelled).
Could be backported.
Closes #283 (closed)