[evolution-data-server/evolution-data-server-3-12] Bug 712392 - Delay server availability checks on network change
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] Bug 712392 - Delay server availability checks on network change
- Date: Fri, 24 Oct 2014 07:27:03 +0000 (UTC)
commit d5d4e25549e2a777d0a6f0bb91719f55588e7d1c
Author: Milan Crha <mcrha redhat com>
Date: Fri Oct 24 09:23:42 2014 +0200
Bug 712392 - Delay server availability checks on network change
camel/camel-network-service.c | 32 ++++++++++++++++++++++----------
libebackend/e-backend.c | 29 ++++++++++++++++++++---------
2 files changed, 42 insertions(+), 19 deletions(-)
---
diff --git a/camel/camel-network-service.c b/camel/camel-network-service.c
index c54f284..5016562 100644
--- a/camel/camel-network-service.c
+++ b/camel/camel-network-service.c
@@ -460,19 +460,25 @@ network_service_set_host_reachable (CamelNetworkService *service,
camel_service_disconnect_sync (
CAMEL_SERVICE (service), FALSE, NULL, &local_error);
if (local_error != NULL) {
- g_warning ("%s: %s", G_STRFUNC, local_error->message);
+ if (!G_IS_IO_ERROR (local_error, G_IO_ERROR_CANCELLED))
+ g_warning ("%s: %s", G_STRFUNC, local_error->message);
g_error_free (local_error);
}
}
}
static gboolean
-network_service_update_host_reachable_idle_cb (gpointer user_data)
+network_service_update_host_reachable_timeout_cb (gpointer user_data)
{
CamelNetworkService *service;
CamelNetworkServicePrivate *priv;
GCancellable *old_cancellable;
GCancellable *new_cancellable;
+ GSource *current_source;
+
+ current_source = g_main_current_source ();
+ if (current_source && g_source_is_destroyed (current_source))
+ return FALSE;
service = CAMEL_NETWORK_SERVICE (user_data);
priv = CAMEL_NETWORK_SERVICE_GET_PRIVATE (service);
@@ -519,22 +525,28 @@ network_service_update_host_reachable (CamelNetworkService *service)
g_mutex_lock (&priv->update_host_reachable_lock);
+ if (priv->update_host_reachable) {
+ g_source_destroy (priv->update_host_reachable);
+ g_source_unref (priv->update_host_reachable);
+ priv->update_host_reachable = NULL;
+ }
+
if (priv->update_host_reachable == NULL) {
GMainContext *main_context;
- GSource *idle_source;
+ GSource *timeout_source;
main_context = camel_session_ref_main_context (session);
- idle_source = g_idle_source_new ();
- g_source_set_priority (idle_source, G_PRIORITY_LOW);
+ timeout_source = g_timeout_source_new_seconds (5);
+ g_source_set_priority (timeout_source, G_PRIORITY_LOW);
g_source_set_callback (
- idle_source,
- network_service_update_host_reachable_idle_cb,
+ timeout_source,
+ network_service_update_host_reachable_timeout_cb,
g_object_ref (service),
(GDestroyNotify) g_object_unref);
- g_source_attach (idle_source, main_context);
- priv->update_host_reachable = g_source_ref (idle_source);
- g_source_unref (idle_source);
+ g_source_attach (timeout_source, main_context);
+ priv->update_host_reachable = g_source_ref (timeout_source);
+ g_source_unref (timeout_source);
g_main_context_unref (main_context);
}
diff --git a/libebackend/e-backend.c b/libebackend/e-backend.c
index d3189d5..46045c4 100644
--- a/libebackend/e-backend.c
+++ b/libebackend/e-backend.c
@@ -126,11 +126,16 @@ backend_network_monitor_can_reach_cb (GObject *source_object,
}
static gboolean
-backend_update_online_state_idle_cb (gpointer user_data)
+backend_update_online_state_timeout_cb (gpointer user_data)
{
EBackend *backend;
GSocketConnectable *connectable;
GCancellable *cancellable;
+ GSource *current_source;
+
+ current_source = g_main_current_source ();
+ if (current_source && g_source_is_destroyed (current_source))
+ return FALSE;
backend = E_BACKEND (user_data);
connectable = e_backend_ref_connectable (backend);
@@ -188,23 +193,29 @@ backend_update_online_state (EBackend *backend)
{
g_mutex_lock (&backend->priv->update_online_state_lock);
+ if (backend->priv->update_online_state) {
+ g_source_destroy (backend->priv->update_online_state);
+ g_source_unref (backend->priv->update_online_state);
+ backend->priv->update_online_state = NULL;
+ }
+
if (backend->priv->update_online_state == NULL) {
GMainContext *main_context;
- GSource *idle_source;
+ GSource *timeout_source;
main_context = e_backend_ref_main_context (backend);
- idle_source = g_idle_source_new ();
- g_source_set_priority (idle_source, G_PRIORITY_LOW);
+ timeout_source = g_timeout_source_new_seconds (5);
+ g_source_set_priority (timeout_source, G_PRIORITY_LOW);
g_source_set_callback (
- idle_source,
- backend_update_online_state_idle_cb,
+ timeout_source,
+ backend_update_online_state_timeout_cb,
g_object_ref (backend),
(GDestroyNotify) g_object_unref);
- g_source_attach (idle_source, main_context);
+ g_source_attach (timeout_source, main_context);
backend->priv->update_online_state =
- g_source_ref (idle_source);
- g_source_unref (idle_source);
+ g_source_ref (timeout_source);
+ g_source_unref (timeout_source);
g_main_context_unref (main_context);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]