circuit: Cleanup an HS circuit when it is being re-purposed
Mike found out that when an IP/RP circuit fails to build in the right amount of time (for instance through
circuit_expire_building()), it is re-purposed to become a measurement circuit.
The issue is that those HS circuits are set in the HS circuitmap and have an
rend_data set to them that should really not linger in the circuit object if the circuit is not an HS one anymore.
circuit_change_purpose() is probably the right place to make a callback within the HS subsystem specific to cleaning up a circuit for a purpose change. I think we need a new function that specifically does that and not use
hs_circ_cleanup() since it won't remove the ident.
Lingering circuits in the HS circuitmap is bad and this bug could probably explain some of the issues we had with clients unable to establish connections because the IP auth key wouldn't match the one in the circuit ident.
I strongly believe this should be backported up to 0.3.5 at the very least.