Factor out SQL retries
Factor out SQL retries

Test if sqlite is multithreading-safe and bail out if not. sqlite
versions since at least 2008 are.
But, as it still causes errors when 2
threads try to write to the same connection simultanously (We get a
"cannot start transaction within a transaction" error), we protect
writes with a per class, ie per-connection lock. Factor out the retrying
to write when the database is locked.

Signed-off-by: Sebastian Spaeth <98dcb2717ddae152d5b359c6ea97e4fe34a29d4c@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <347709267ddd1958560c4c317ea3fd613f10a719@laposte.net>

frioux/offlineimap,frioux/offlineimap