diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2018-01-01 06:05:12 -0800 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2018-01-09 07:53:28 -0800 |
commit | 3afdbaf65143fa43b90cd5096b7e64500a1fa8c3 (patch) | |
tree | d767894ff49142bb38e3e0533f59e6cc5a69888a | |
parent | 8d6d960153d98353dc4a1bc7e60e3973d1607ac3 (diff) |
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 <patrick.ohly@intel.com>
-rw-r--r-- | src/backends/evolution/EvolutionSyncSource.cpp | 16 |
1 files 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 == "<<system>>")) { @@ -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); } |