[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-talk] How to make the Tor service to stop faster?



On Mon, 15 Feb 2016 11:48:45 +0000, Ken Cline wrote:
> > On 15 Feb 2016, at 7:22 AM, nusenu <nusenu@xxxxxxxxxxxxxxx> wrote:
...
> > It is just the nicer way to say goodbye to clients - I guess.

Also, tor then has a chance to gracefully shut down circuits so
that at least short-lived connections don't break by the shutdown.

> I bet shutdown delay has to have something to do with TCP connection finalization semantics,

Nope.

> which can leave client processes stuck in a FIN_WAIT_2 state if tor
> closes too quickly.  My memory is a little vague here, but it is a result
> of interrupting the FIN-> ACK<- FIN<- ACK-> dialogue ... the client
> won't close the connection until it receive's that last ACK form tor,
> which tor can't send if it closes before it gets the client's FIN.

If a socket is stuck in FIN_WAIT_2 then the connection is half-closed,
the local side has sent its FIN and got the ACK, but the other side
didn't close its direction by sending its FIN.

It doesn't actually matter whether the tor process is still alive or
not - the kernel keeps the socket existing even when tor has terminated.

The only reason why keeping tor around for a bit helps here may be
that, when shutting down, it sends some sort of close message that
causes the other side to close as well, and it doesn't when it is
hard-killed, *and* the other side then won't shutdown the socket.

Would surprise me for tor-tor connections.

> Then it's up to the TCP stack to close the connection after it times out.

The fun part is that strictly there can be no timeout on FIN_WAIT_2. The
other side is still permitted to send data, and to do so infinitely long.
Practially, there often is a timeout.

An'on borrowed time'dreas

-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
-- 
tor-talk mailing list - tor-talk@xxxxxxxxxxxxxxxxxxxx
To unsubscribe or change other settings go to
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-talk