Try to simplify apoptosis/DeleteConnection locking mess.
Select() error code is no longer lost because of recv().
(cherry picked from commit 56afde78024563bc1daf6e3a5f8f44b65f3b04e5)
Merge pull request #1677 from jimis/serverd_deadlock_fix-3.6.x

Serverd deadlock fix 3.6.x
Don't use Read/WriteDB inside a cursor loop.

LMDB doesn't allow multiple transactions per thread. Opening a cursor
opens a transaction, and so does Read/WriteDB. So, either re-use values
from cursor, or populate a sequence with keys, and then lookup the
individual values in a separate loop.

Note: Previously, the WriteDB code reused the transaction from an open
cursor, but that is making the entire LMDB driver not thread-safe.

(cherry picked from commit 683df34e32c822e6d26dd4c5cc562881269acd6a)
Remove all transaction sharing code between cursor and regular updates.

Modifying the db structure makes the individual functions non-reentrant,
and can cause race conditions and data corruptions in multi threaded
programs, such as cf-serverd.

(cherry picked from commit 48a63e90bf635e78081da97ac61d24f4b5710e65)
Disable irrelevant migration tests for LMDB builds.

(cherry picked from commit fce7530cfa0e5ea1fdc3787f9817fa09d9f7fadb)

These tests fail because the used functions use WriteDB inside
a cursor loop. This opens two transactions at the same time, which
LMDB doesn't allow - the result is a deadlock after removing
transaction sharing between cursors and WriteDB calls.

Since LMDB was introduced in 3.6, the migration code won't work
anyway - the old database would be a TCDB database.
Initialize the global transaction to null at initialization.

Otherwise, we have an uninitialized pointer in case of error.
Also abort the opening transaction in case of error.

No need to reset the pointer on the stack at end of function.

(cherry picked from commit 88e3e9623273df3ac9a86ee0147492f7ac6d5005)
Add LoadDatabaseToStringMap utility function

(cherry picked from commit 976464db62381a598b470304cebaf0e490ea5227)
Fix linker errors in unit tests.
(cherry picked from commit 7a85c9a0b6e825a164e5b5c9921bc869e95759f4)