Single DB transaction for addresses from DNS seeds
Backported from bitcoin commit d655a26c9dd157a9e4bf08bff14bfaa69791287a
Fix some address-handling deadlocks

Made three critical blocks for cs_mapAddresses smaller, and moved
writing to the database out of them. This should also improve the
concurrency of the code.

Backported partialy from bitcoin commit a75d7066b824eb1e70fb5b0e0e7c3c122e00c4b6
Merge branch 'deadlock-fixes' into deadlock-fixes2
Fix crashes when a wallet is locked and GetReservedKey() is called
Add DEBUG_LOCKCONTENTION, to warn each time a thread waits to lock.

If compiled with -DDEBUG_LOCKCONTENTION, Bitcoin will print to
debug.log each time a thread has to wait for a lock to continue.
Revert "Fix crashes when a wallet is locked and GetReservedKey() is called"

This reverts commit f01a0c956d11e40fe3492313e786d11520d4c092.
Macros for manual critical sections
Fix wallet locking locking

Backported from bitcoin commit b0529ffd951fdaa7ecc823381a6a7b0c88b5b2b0
Locking system overhaul, add condition variables

This commit simplifies the locking system: CCriticalSection becomes a
simple typedef for boost::interprocess::interprocess_recursive_mutex,
and CCriticalBlock and CTryCriticalBlock are replaced by a templated
CMutexLock, which wraps boost::interprocess::scoped_lock.

By making the lock type a template parameter, some critical sections
can now be changed to non-recursive locks, which support waiting via
condition variables. These are implemented in CWaitableCriticalSection
and WAITABLE_CRITICAL_BLOCK.

CWaitableCriticalSection is a wrapper for a different Boost mutex,
which supports waiting/notification via condition variables. This
should enable us to remove much of the used polling code. Important
is that this mutex is not recursive, so functions that perform the
locking must not call eachother.

Because boost::interprocess::scoped_lock does not support assigning
and copying, I had to revert to the older CRITICAL_BLOCK macros that
use a nested for loop instead of a simple if.

Backported from bitcoin commit 712fd182b72b0f5a1bcf843f171c29ec0a49b50f