[evolution-data-server] [IMAPx] Circle between tagprefix-es for connections
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] [IMAPx] Circle between tagprefix-es for connections
- Date: Thu, 27 Nov 2014 15:17:53 +0000 (UTC)
commit a615f9a77e7fb843b3b0645142fddd7b750087bd
Author: Milan Crha <mcrha redhat com>
Date: Thu Nov 27 16:12:37 2014 +0100
[IMAPx] Circle between tagprefix-es for connections
Even the connection manager didn't use tag prefixes which were used
by other connections, it was using always the same connection tag
prefix for the last connection which was closed, because it was
picking the tag prefix always from 'A'. While it might not be an issue
to close the connection with one tag prefix and start a new connection
with the same tag prefix to the same server, then it looks better
to change also the tag prefix (which can be eventually observed
in a debug log as well).
camel/providers/imapx/camel-imapx-conn-manager.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-conn-manager.c
b/camel/providers/imapx/camel-imapx-conn-manager.c
index 3471e1b..505cba0 100644
--- a/camel/providers/imapx/camel-imapx-conn-manager.c
+++ b/camel/providers/imapx/camel-imapx-conn-manager.c
@@ -50,6 +50,8 @@ struct _CamelIMAPXConnManagerPrivate {
GMutex pending_connections_lock;
GSList *pending_connections; /* GCancellable * */
+
+ gchar last_tagprefix;
};
struct _ConnectionInfo {
@@ -474,6 +476,8 @@ camel_imapx_conn_manager_init (CamelIMAPXConnManager *con_man)
g_rw_lock_init (&con_man->priv->rw_lock);
g_mutex_init (&con_man->priv->pending_connections_lock);
g_weak_ref_init (&con_man->priv->store, NULL);
+
+ con_man->priv->last_tagprefix = 'A' - 1;
}
static void
@@ -721,11 +725,18 @@ static gchar
imapx_conn_manager_get_next_free_tagprefix_unlocked (CamelIMAPXConnManager *con_man)
{
gchar adept;
+ gint ii;
GList *iter;
+ adept = con_man->priv->last_tagprefix + 1;
+
/* the 'Z' is dedicated to auth types query */
- adept = 'A';
- while (adept < 'Z') {
+ if (adept >= 'Z')
+ adept = 'A';
+ else if (adept < 'A')
+ adept = 'A';
+
+ for (ii = 0; ii < 26; ii++) {
for (iter = con_man->priv->connections; iter; iter = g_list_next (iter)) {
ConnectionInfo *cinfo = iter->data;
@@ -741,10 +752,14 @@ imapx_conn_manager_get_next_free_tagprefix_unlocked (CamelIMAPXConnManager *con_
break;
adept++;
+ if (adept >= 'Z')
+ adept = 'A';
}
g_return_val_if_fail (adept >= 'A' && adept < 'Z', 'Z');
+ con_man->priv->last_tagprefix = adept;
+
return adept;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]