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.