[evolution-ews] Stale connection used after resume
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Stale connection used after resume
- Date: Thu, 26 Apr 2018 07:12:25 +0000 (UTC)
commit 1ec1802a0832924f2017a67134f6097617757699
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 26 09:13:09 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 50f93de..ffb0630 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -2079,6 +2079,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 4414b4e..3904e71 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 5974754..28aff74 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 0cdb467..2de3805 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -109,6 +109,9 @@ struct _EEwsConnectionPrivate {
EEwsServerVersion version;
gboolean backoff_enabled;
+
+ /* Set to TRUE when this connection had been disconnected and cannot be used anymore */
+ gboolean disconnected_flag;
};
enum {
@@ -1906,9 +1909,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;
@@ -2073,6 +2076,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->backoff_enabled = TRUE;
+ cnc->priv->disconnected_flag = FALSE;
cnc->priv->subscriptions = g_hash_table_new_full (
g_direct_hash, g_direct_equal,
@@ -2338,7 +2342,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;
@@ -2372,7 +2377,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));
}
}
@@ -2422,7 +2427,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);
@@ -2792,6 +2798,23 @@ e_ews_connection_set_backoff_enabled (EEwsConnection *cnc,
cnc->priv->backoff_enabled = enabled;
}
+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 30d4ff5..fa8edc9 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -456,6 +456,11 @@ gboolean e_ews_connection_get_backoff_enabled
void e_ews_connection_set_backoff_enabled
(EEwsConnection *cnc,
gboolean enabled);
+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]