From 3afdbaf65143fa43b90cd5096b7e64500a1fa8c3 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 1 Jan 2018 06:05:12 -0800 Subject: EDS: more generic open retry handling Recent EDS started to exhibit race conditions when opening a database (for example, https://bugzilla.gnome.org/show_bug.cgi?id=791306). Opening was already tried again for a certain known error in some old EDS version. Now it is tried five times with a delay of one second for all errors. The advantage is that this does not depend on accurately detecting the race condition error. Signed-off-by: Patrick Ohly --- src/backends/evolution/EvolutionSyncSource.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/backends/evolution/EvolutionSyncSource.cpp b/src/backends/evolution/EvolutionSyncSource.cpp index 57f20e40..8643b56d 100644 --- a/src/backends/evolution/EvolutionSyncSource.cpp +++ b/src/backends/evolution/EvolutionSyncSource.cpp @@ -66,7 +66,6 @@ EClientCXX EvolutionSyncSource::openESource(const char *extension, ESourceListCXX sources(e_source_registry_list_sources(registry, extension)); string id = getDatabaseID(); ESource *source = findSource(sources, id); - bool created = false; if (!source) { if (refBuiltin && (id.empty() || id == "<>")) { @@ -78,7 +77,6 @@ EClientCXX EvolutionSyncSource::openESource(const char *extension, } else { throwError(SE_HERE, string("database not found: '") + id + "'"); } - created = true; } else { client = EClientCXX::steal(newClient(source, gerror)); } @@ -95,19 +93,19 @@ EClientCXX EvolutionSyncSource::openESource(const char *extension, (void *)"Evolution Data Server has died unexpectedly."); + int retries = 0; while (true) { // Always allow EDS to create the database. "only-if-exists = // true" does not make sense. if (!e_client_open_sync(client, false, NULL, gerror)) { - if (gerror && g_error_matches(gerror, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY)) { + if (retries < 5) { + // EDS 3.18 and 3.26 have various race conditions during startup. + // Try a few times. + // https://bugzilla.gnome.org/show_bug.cgi?id=791306 + SE_LOG_DEBUG(NULL, "Opening EDS source: ignoring error, trying again: %s", gerror->message); gerror.clear(); sleep(1); - } else if (created) { - // Opening newly created address books often failed in - // old EDS releases - try again. Probably covered by - // more recently added E_CLIENT_ERROR_BUSY check above. - gerror.clear(); - sleep(5); + retries++; } else { throwError(SE_HERE, "opening database", gerror); } -- cgit v1.2.3