When Tor is offline, it doesn't quite run out of relays, so doesn't realize it's offline
If your Tor client goes offline, it will keep trying to establish circuits, and as each TLS connection fails, it will mark that relay down.
In update_router_have_minimum_dir_info() Tor checks whether (num_present < 2) but we never actually mark down the last few relays, either because we don't have enough left to make a circuit so we don't ever try another TLS connection, or because none of the remaining relays are suitable exit nodes so we can't pick a path that would be a useful circuit so we don't try.
I think we need to catch the case where we failed to pick a path because we don't have enough circuits, and if it case occurs and many of our relays are marked down, we should mark them up.
That will cause us to attempt circuits for a lot longer than currently, but on the other hand Tor will actually work when you come back to the network and try to make a new application request.
[Automatically added by flyspray2trac: Operating System: All]