Make CIRCUIT_IS_ORIGIN() look at the base magic number
Currently, CIRCUIT_IS_ORIGIN()
actually looks at the purpose, not the base magic number:
#define CIRCUIT_IS_ORIGIN(c) (CIRCUIT_PURPOSE_IS_ORIGIN((c)->purpose))
We should move it to look at the magic
like CIRCUIT_IS_ORCIRC()
is doing.
The reason is because I was adding tracing events to the circuit subsystem and I kept having state transition event with a circuit global identifier of 0 which can't be because that value is set just after allocation.
But at that point, the purpose has not been set so CIRCUIT_IS_ORIGIN()
wasn't returning true.
Furthermore, this made me discover another issue documented in #31608 (moved) where if we do make this change, we must fix this ticket else we have a NULL deref.