mainloop: make periodic events restartable
When we shut down tor, we disable periodic events, but leave their enabled flag set to 1.
See this PR for details: https://github.com/torproject/tor/pull/1397
I'm not sure if this is the best solution, or how far we should backport.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information