If I understand correctly Tor Browser's "new circuit" attaches new connections to a new circuit while letting old connections finish in the old circuit. It does not clear out cookies, so that domain-isolated user session persists across circuits (for that URL-bar domain).
But what happens to SSL session and DNS cache? Are they reset by "new circuit" or do they persist? Is there anything else that gets reset or that persists?
Furthermore, what happens on Tor Browser's side when the tor process itself changes the circuit on its own because it has become dirty? Does Tor Browser react to that in any way?
The reason for asking is that I'm trying to replicate Tor Browser's "new circuit" with libcurl as exactly as possible, so I'd be really grateful for any implementation details or pointers.
My current "new circuit" implementation retains only cookies while resetting DNS cache and SSL session. It lets existing transfers complete through the old circuit. It's also completely ignorant of the tor process itself resetting dirty circuits on its own, so in that case SSL session and DNS cache are not reset. How well does this match Tor Browser's implementation? Anything else I should be aware of?