aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-wrapper.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-01-24 04:34:50 +0800
committerDan Winship <danw@src.gnome.org>2001-01-24 04:34:50 +0800
commit5d7f815b3eede63ce843c7de7a3d2302c6b93586 (patch)
tree2ff2b1789ad7455a4aaf14304323efd8194ca387 /camel/providers/imap/camel-imap-wrapper.c
parent4028f454b6c274fa093056180af8d11e5c7bfd1e (diff)
downloadgsoc2013-evolution-5d7f815b3eede63ce843c7de7a3d2302c6b93586.tar.gz
gsoc2013-evolution-5d7f815b3eede63ce843c7de7a3d2302c6b93586.tar.zst
gsoc2013-evolution-5d7f815b3eede63ce843c7de7a3d2302c6b93586.zip
Add a lock around the delayed loading, so two threads won't try to do it
* providers/imap/camel-imap-wrapper.c: Add a lock around the delayed loading, so two threads won't try to do it at the same time. svn path=/trunk/; revision=7752
Diffstat (limited to 'camel/providers/imap/camel-imap-wrapper.c')
-rw-r--r--camel/providers/imap/camel-imap-wrapper.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/camel/providers/imap/camel-imap-wrapper.c b/camel/providers/imap/camel-imap-wrapper.c
index 2277b7747f..e4d06a009b 100644
--- a/camel/providers/imap/camel-imap-wrapper.c
+++ b/camel/providers/imap/camel-imap-wrapper.c
@@ -71,6 +71,22 @@ camel_imap_wrapper_finalize (CamelObject *object)
g_free (imap_wrapper->uid);
if (imap_wrapper->part)
g_free (imap_wrapper->part_spec);
+
+#ifdef ENABLE_THREADS
+ g_mutex_free (imap_wrapper->priv->lock);
+#endif
+ g_free (imap_wrapper->priv);
+}
+
+static void
+camel_imap_wrapper_init (gpointer object, gpointer klass)
+{
+ CamelImapWrapper *imap_wrapper = CAMEL_IMAP_WRAPPER (object);
+
+ imap_wrapper->priv = g_new0 (struct _CamelImapWrapperPrivate, 1);
+#ifdef ENABLE_THREADS
+ imap_wrapper->priv->lock = g_mutex_new ();
+#endif
}
CamelType
@@ -85,7 +101,7 @@ camel_imap_wrapper_get_type (void)
sizeof (CamelImapWrapperClass),
(CamelObjectClassInitFunc) camel_imap_wrapper_class_init,
NULL,
- NULL,
+ (CamelObjectInitFunc) camel_imap_wrapper_init,
(CamelObjectFinalizeFunc) camel_imap_wrapper_finalize);
}
@@ -106,8 +122,11 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
char *result, *p, *body;
int len;
- if (!data_wrapper->offline)
+ CAMEL_IMAP_WRAPPER_LOCK (imap_wrapper, lock);
+ if (!data_wrapper->offline) {
+ CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
return parent_class->write_to_stream (data_wrapper, stream);
+ }
store = CAMEL_IMAP_STORE (imap_wrapper->folder->parent_store);
CAMEL_IMAP_STORE_LOCK (store, command_lock);
@@ -180,9 +199,12 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
g_free (imap_wrapper->part_spec);
imap_wrapper->part = NULL;
+ CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
+
return parent_class->write_to_stream (data_wrapper, stream);
lose:
+ CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
errno = ENETUNREACH;
return -1;
}