[evolution-ews/gnome-3-28] Stale connection used after resume
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-3-28] Stale connection used after resume
- Date: Thu, 26 Apr 2018 07:19:46 +0000 (UTC)
commit 16b3999934d02a123537f36b4c792899b114f444
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 26 09:21:05 2018 +0200
Stale connection used after resume
This is a just-in-case change, which avoids re-using connection which
had been reported as offline (when the backend/store disconnected).
Reported downstream at:
https://bugzilla.redhat.com/show_bug.cgi?id=1567572
src/addressbook/e-book-backend-ews.c | 2 +
src/calendar/e-cal-backend-ews.c | 2 +
src/camel/camel-ews-store.c | 1 +
src/server/e-ews-connection.c | 35 ++++++++++++++++++++++++++++-----
src/server/e-ews-connection.h | 5 ++++
5 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 1957a36..d19050c 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -1913,6 +1913,8 @@ ebb_ews_unset_connection (EBookBackendEws *bbews)
g_rec_mutex_lock (&bbews->priv->cnc_lock);
if (bbews->priv->cnc) {
+ e_ews_connection_set_disconnected_flag (bbews->priv->cnc, TRUE);
+
g_signal_handlers_disconnect_by_func (bbews->priv->cnc, ebb_ews_server_notification_cb,
bbews);
if (bbews->priv->subscription_key != 0) {
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 918c0cd..81b8bb2 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -245,6 +245,8 @@ ecb_ews_unset_connection (ECalBackendEws *cbews)
g_rec_mutex_lock (&cbews->priv->cnc_lock);
if (cbews->priv->cnc) {
+ e_ews_connection_set_disconnected_flag (cbews->priv->cnc, TRUE);
+
g_signal_handlers_disconnect_by_func (cbews->priv->cnc, ecb_ews_server_notification_cb,
cbews);
if (cbews->priv->subscription_key != 0) {
diff --git a/src/camel/camel-ews-store.c b/src/camel/camel-ews-store.c
index d309277..7cf14ca 100644
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@ -1396,6 +1396,7 @@ ews_store_unset_connection_locked (CamelEwsStore *ews_store)
}
e_ews_connection_set_password (ews_store->priv->connection, NULL);
+ e_ews_connection_set_disconnected_flag (ews_store->priv->connection, TRUE);
g_signal_handlers_disconnect_by_func (ews_store->priv->connection,
G_CALLBACK (camel_ews_store_password_will_expire_cb), ews_store);
g_object_unref (ews_store->priv->connection);
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index a0bae8b..cd44bd0 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -108,6 +108,9 @@ struct _EEwsConnectionPrivate {
GSList *subscribed_folders;
EEwsServerVersion version;
+
+ /* Set to TRUE when this connection had been disconnected and cannot be used anymore */
+ gboolean disconnected_flag;
};
enum {
@@ -1905,9 +1908,9 @@ ews_connection_dispose (GObject *object)
g_mutex_lock (&connecting);
/* remove the connection from the hash table */
- if (loaded_connections_permissions != NULL) {
- g_hash_table_remove (
- loaded_connections_permissions, priv->hash_key);
+ if (loaded_connections_permissions != NULL &&
+ g_hash_table_lookup (loaded_connections_permissions, priv->hash_key) == (gpointer) object) {
+ g_hash_table_remove (loaded_connections_permissions, priv->hash_key);
if (g_hash_table_size (loaded_connections_permissions) == 0) {
g_hash_table_destroy (loaded_connections_permissions);
loaded_connections_permissions = NULL;
@@ -2071,6 +2074,7 @@ e_ews_connection_init (EEwsConnection *cnc)
cnc->priv->soup_context = g_main_context_new ();
cnc->priv->soup_loop = g_main_loop_new (cnc->priv->soup_context, FALSE);
+ cnc->priv->disconnected_flag = FALSE;
cnc->priv->subscriptions = g_hash_table_new_full (
g_direct_hash, g_direct_equal,
@@ -2336,7 +2340,8 @@ e_ews_connection_find (const gchar *uri,
loaded_connections_permissions, hash_key);
g_free (hash_key);
- if (E_IS_EWS_CONNECTION (cnc)) {
+ if (E_IS_EWS_CONNECTION (cnc) &&
+ !e_ews_connection_get_disconnected_flag (cnc)) {
g_object_ref (cnc);
g_mutex_unlock (&connecting);
return cnc;
@@ -2370,7 +2375,7 @@ e_ews_connection_list_existing (void)
g_hash_table_iter_init (&iter, loaded_connections_permissions);
while (g_hash_table_iter_next (&iter, NULL, &value)) {
- if (value)
+ if (value && !e_ews_connection_get_disconnected_flag (value))
connections = g_slist_prepend (connections, g_object_ref (value));
}
}
@@ -2420,7 +2425,8 @@ e_ews_connection_new_full (ESource *source,
cnc = g_hash_table_lookup (
loaded_connections_permissions, hash_key);
- if (E_IS_EWS_CONNECTION (cnc)) {
+ if (E_IS_EWS_CONNECTION (cnc) &&
+ !e_ews_connection_get_disconnected_flag (cnc)) {
g_object_ref (cnc);
g_free (hash_key);
@@ -2773,6 +2779,23 @@ e_ews_connection_ref_soup_session (EEwsConnection *cnc)
return g_object_ref (cnc->priv->soup_session);
}
+gboolean
+e_ews_connection_get_disconnected_flag (EEwsConnection *cnc)
+{
+ g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), FALSE);
+
+ return cnc->priv->disconnected_flag;
+}
+
+void
+e_ews_connection_set_disconnected_flag (EEwsConnection *cnc,
+ gboolean disconnected_flag)
+{
+ g_return_if_fail (E_IS_EWS_CONNECTION (cnc));
+
+ cnc->priv->disconnected_flag = disconnected_flag;
+}
+
static xmlDoc *
e_ews_autodiscover_ws_xml (const gchar *email_address)
{
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index 108205f..76f8cf6 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -450,6 +450,11 @@ CamelEwsSettings *
e_ews_connection_ref_settings (EEwsConnection *cnc);
SoupSession * e_ews_connection_ref_soup_session
(EEwsConnection *cnc);
+gboolean e_ews_connection_get_disconnected_flag
+ (EEwsConnection *cnc);
+void e_ews_connection_set_disconnected_flag
+ (EEwsConnection *cnc,
+ gboolean disconnected_flag);
EEwsConnection *e_ews_connection_find (const gchar *uri,
const gchar *username);
GSList * e_ews_connection_list_existing (void); /* EEwsConnection * */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]