Attempt to handle threading-related issues with extension reloading.

We observed some issues in a mod_worker environment where attempts to
reload extensions would fail, causing state to become corrupted, leading
to more and more errors. Some of these cases were made more
bullet-proof, but we didn't fix the core issue.

This change attempts to prevent what may be causing the issue by
allowing only one thread to reload the list of extensions at a time.

We have a lock set up for reloading extensions (in case two users try to
reload in the admin UI at the same time).

There's a separate lock in the middleware that's a bit smarter about
calling load(). It checks if the extension state has expired, tries to
grab a lock, and then checks again for expiration. The goal there is to
not have a bunch of threads that are waiting decide they're all going to
trigger their own reloads.

Unit tests have been written that hit issues both during uninit and
during init of extensions. These mirror the errors we've been getting
on reviews.reviewboard.org with Review Bot. With the fix, these tests
pass.

Reviewed at https://reviews.reviewboard.org/r/5866/