Test db->mc only once and store result on stack.

This reduces the possibility of race conditions in multi threaded
client code, where one thread opens a cursor while another thread
operates on the DB without cursors. In that case, db->mc changes
in the middle of the operation.

This is a quick workaround, the correct fix is to either remove this
optimization or protect the db structure with a mutex.
Merge pull request #1673 from vohi/mitigate_racecondition

Test db->mc only once and store result on stack.
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.
Merge pull request #1674 from vohi/mitigate_racecondition

Remove all transaction sharing code between cursor and regular updates.
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.
Disable irrelevant migration tests for LMDB builds.
Merge pull request #1675 from vohi/disable_migration_tests

Disable irrelevant migration tests for LMDB builds.
Try to simplify apoptosis/DeleteConnection locking mess.
Select() error code is no longer lost because of recv().
Merge pull request #1678 from jimis/select_error_lost

Select() error code is no longer lost because of recv().
Merge pull request #1676 from jimis/serverd_deadlock_fix

Try to simplify apoptosis/DeleteConnection locking mess.
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.
Merge pull request #1679 from vohi/fix_db_cursor_usage

Don't use Read/WriteDB inside a cursor loop.
Add LoadDatabaseToStringMap utility function
Merge pull request #1680 from maciejmrowiec/master

Add LoadDatabaseToStringMap utility function
Remove superflous include.

cf-key uses functions from lastseen, not the DB API directly.
Fix linker errors in unit tests.