aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-06-28 06:43:00 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-06-28 06:43:00 +0800
commit3797918d013db678b61d62956ed14ad50e7b70e1 (patch)
tree62a8952d650f0013e99f5519b084398f6a3459b8
parent5a223c85b94c5cc51fe5e830665cabd981e4c75b (diff)
downloadgsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.tar
gsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.tar.gz
gsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.tar.bz2
gsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.tar.lz
gsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.tar.xz
gsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.tar.zst
gsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.zip
Initialize the private send_lock. (camel_transport_finalize): Free the
2001-06-27 Jeffrey Stedfast <fejj@ximian.com> * camel-transport.c (camel_transport_init): Initialize the private send_lock. (camel_transport_finalize): Free the private send_lock. (camel_transport_get_type): Set the init and finalize functions. (camel_transport_send): Lock the transport. (camel_transport_send_to): Same. * camel-private.h: Add CAMEL_TRANSPORT_(UN)LOCK macros. svn path=/trunk/; revision=10547
-rw-r--r--camel/ChangeLog11
-rw-r--r--camel/camel-private.h14
-rw-r--r--camel/camel-transport.c47
-rw-r--r--camel/camel-transport.h2
4 files changed, 70 insertions, 4 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 7bcee459fa..dfafd7d909 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,16 @@
2001-06-27 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-transport.c (camel_transport_init): Initialize the private
+ send_lock.
+ (camel_transport_finalize): Free the private send_lock.
+ (camel_transport_get_type): Set the init and finalize functions.
+ (camel_transport_send): Lock the transport.
+ (camel_transport_send_to): Same.
+
+ * camel-private.h: Add CAMEL_TRANSPORT_(UN)LOCK macros.
+
+2001-06-27 Jeffrey Stedfast <fejj@ximian.com>
+
* tests/folder/test9.c (main): Updated to match the current API.
* tests/folder/test3.c: #include <gtk/gtk.h> since we use
diff --git a/camel/camel-private.h b/camel/camel-private.h
index fa9b50a8a0..f63a452a4c 100644
--- a/camel/camel-private.h
+++ b/camel/camel-private.h
@@ -73,6 +73,20 @@ struct _CamelStorePrivate {
#define CAMEL_STORE_UNLOCK(f, l)
#endif
+struct _CamelTransportPrivate {
+#ifdef ENABLE_THREADS
+ GMutex *send_lock; /* for locking send operations */
+#endif
+};
+
+#ifdef ENABLE_THREADS
+#define CAMEL_TRANSPORT_LOCK(f, l) (g_mutex_lock(((CamelTransport *)f)->priv->l))
+#define CAMEL_TRANSPORT_UNLOCK(f, l) (g_mutex_unlock(((CamelTransport *)f)->priv->l))
+#else
+#define CAMEL_TRANSPORT_LOCK(f, l)
+#define CAMEL_TRANSPORT_UNLOCK(f, l)
+#endif
+
struct _CamelServicePrivate {
#ifdef ENABLE_THREADS
EMutex *connect_lock; /* for locking connection operations */
diff --git a/camel/camel-transport.c b/camel/camel-transport.c
index 5d902ddd33..0338f5dcc0 100644
--- a/camel/camel-transport.c
+++ b/camel/camel-transport.c
@@ -30,10 +30,33 @@
#include "camel-transport.h"
#include "camel-exception.h"
+#include "camel-private.h"
/* Returns the class for a CamelTransport */
#define CT_CLASS(so) CAMEL_TRANSPORT_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static void
+camel_transport_init (gpointer object, gpointer klass)
+{
+ CamelTransport *xport = object;
+
+ xport->priv = g_malloc0 (sizeof (struct _CamelTransportPrivate));
+#ifdef ENABLE_THREADS
+ xport->priv->send_lock = g_mutex_new ();
+#endif
+}
+
+static void
+camel_transport_finalize (CamelObject *object)
+{
+ CamelTransport *xport = CAMEL_TRANSPORT (object);
+
+#ifdef ENABLE_THREADS
+ g_mutex_free (xport->priv->send_lock);
+#endif
+ g_free (xport->priv);
+}
+
CamelType
camel_transport_get_type (void)
{
@@ -45,8 +68,8 @@ camel_transport_get_type (void)
sizeof (CamelTransportClass),
NULL,
NULL,
- NULL,
- NULL);
+ (CamelObjectInitFunc) camel_transport_init,
+ (CamelObjectFinalizeFunc) camel_transport_finalize);
}
return camel_transport_type;
@@ -84,7 +107,15 @@ gboolean
camel_transport_send (CamelTransport *transport, CamelMedium *message,
CamelException *ex)
{
- return CT_CLASS (transport)->send (transport, message, ex);
+ gboolean sent;
+
+ g_return_val_if_fail (CAMEL_IS_TRANSPORT (transport), FALSE);
+
+ CAMEL_TRANSPORT_LOCK (transport, send_lock);
+ sent = CT_CLASS (transport)->send (transport, message, ex);
+ CAMEL_TRANSPORT_UNLOCK (transport, send_lock);
+
+ return sent;
}
/**
@@ -103,6 +134,14 @@ gboolean
camel_transport_send_to (CamelTransport *transport, CamelMedium *message,
GList *recipients, CamelException *ex)
{
- return CT_CLASS (transport)->send_to (transport, message,
+ gboolean sent;
+
+ g_return_val_if_fail (CAMEL_IS_TRANSPORT (transport), FALSE);
+
+ CAMEL_TRANSPORT_LOCK (transport, send_lock);
+ sent = CT_CLASS (transport)->send_to (transport, message,
recipients, ex);
+ CAMEL_TRANSPORT_UNLOCK (transport, send_lock);
+
+ return sent;
}
diff --git a/camel/camel-transport.h b/camel/camel-transport.h
index ae6ca50f40..a4693bdab3 100644
--- a/camel/camel-transport.h
+++ b/camel/camel-transport.h
@@ -47,6 +47,8 @@ struct _CamelTransport
{
CamelService parent_object;
+ struct _CamelTransportPrivate *priv;
+
gboolean supports_8bit;
};