diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-06-28 06:43:00 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-06-28 06:43:00 +0800 |
commit | 3797918d013db678b61d62956ed14ad50e7b70e1 (patch) | |
tree | 62a8952d650f0013e99f5519b084398f6a3459b8 /camel/camel-transport.c | |
parent | 5a223c85b94c5cc51fe5e830665cabd981e4c75b (diff) | |
download | gsoc2013-evolution-3797918d013db678b61d62956ed14ad50e7b70e1.tar.gz 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
Diffstat (limited to 'camel/camel-transport.c')
-rw-r--r-- | camel/camel-transport.c | 47 |
1 files changed, 43 insertions, 4 deletions
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; } |