diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-12-14 04:38:11 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-12-14 04:38:11 +0800 |
commit | 66587d89a30adfd7251dfd586e6213f9e9c536a0 (patch) | |
tree | f67f41fe3a63c1e1ceda889068eb7bc4c506381f | |
parent | e2f8314f13c805cc9991f604f8609723ed1ec372 (diff) | |
download | gsoc2013-evolution-66587d89a30adfd7251dfd586e6213f9e9c536a0.tar gsoc2013-evolution-66587d89a30adfd7251dfd586e6213f9e9c536a0.tar.gz gsoc2013-evolution-66587d89a30adfd7251dfd586e6213f9e9c536a0.tar.bz2 gsoc2013-evolution-66587d89a30adfd7251dfd586e6213f9e9c536a0.tar.lz gsoc2013-evolution-66587d89a30adfd7251dfd586e6213f9e9c536a0.tar.xz gsoc2013-evolution-66587d89a30adfd7251dfd586e6213f9e9c536a0.tar.zst gsoc2013-evolution-66587d89a30adfd7251dfd586e6213f9e9c536a0.zip |
Keep a name-to-type hash so that we can make sure that the type has not
2001-12-11 Jeffrey Stedfast <fejj@ximian.com>
* camel-object.c (camel_type_register): Keep a name-to-type hash
so that we can make sure that the type has not yet been registered
(prevents a race condition such as the one in bug #16559).
* camel-service.c (camel_service_connect): Make sure that the
connect_op is non-NULL before unregistering/unreffing it.
svn path=/trunk/; revision=15021
-rw-r--r-- | camel/ChangeLog | 9 | ||||
-rw-r--r-- | camel/camel-digest-folder.c | 14 | ||||
-rw-r--r-- | camel/camel-object.c | 20 | ||||
-rw-r--r-- | camel/camel-service.c | 11 |
4 files changed, 38 insertions, 16 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 319d5c47c3..5f64920987 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,12 @@ +2001-12-11 Jeffrey Stedfast <fejj@ximian.com> + + * camel-object.c (camel_type_register): Keep a name-to-type hash + so that we can make sure that the type has not yet been registered + (prevents a race condition such as the one in bug #16559). + + * camel-service.c (camel_service_connect): Make sure that the + connect_op is non-NULL before unregistering/unreffing it. + 2001-12-04 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-utils.c (header_content_type_simple): Protect against diff --git a/camel/camel-digest-folder.c b/camel/camel-digest-folder.c index 661b81c4ab..f6cf3e8a93 100644 --- a/camel/camel-digest-folder.c +++ b/camel/camel-digest-folder.c @@ -55,13 +55,13 @@ static CamelMessageInfo *digest_get_message_info (CamelFolder *folder, const cha /* message manipulation */ static CamelMimeMessage *digest_get_message (CamelFolder *folder, const gchar *uid, - CamelException *ex); + CamelException *ex); static void digest_append_message (CamelFolder *folder, CamelMimeMessage *message, - const CamelMessageInfo *info, CamelException *ex); + const CamelMessageInfo *info, CamelException *ex); static void digest_copy_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex); + CamelFolder *destination, CamelException *ex); static void digest_move_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex); + CamelFolder *destination, CamelException *ex); static void @@ -190,13 +190,13 @@ digest_refresh_info (CamelFolder *folder, CamelException *ex) static void digest_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) { - + /* no-op */ } static void digest_expunge (CamelFolder *folder, CamelException *ex) { - + /* no-op */ } static GPtrArray * @@ -272,7 +272,7 @@ digest_append_message (CamelFolder *folder, CamelMimeMessage *message, static void digest_copy_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex) + CamelFolder *destination, CamelException *ex) { /* no-op */ } diff --git a/camel/camel-object.c b/camel/camel-object.c index 6d8b301f80..776d22e038 100644 --- a/camel/camel-object.c +++ b/camel/camel-object.c @@ -123,6 +123,7 @@ G_LOCK_DEFINE_STATIC (refcount); static gboolean type_system_initialized = FALSE; static GHashTable *ctype_to_typeinfo = NULL; +static GHashTable *name_to_typeinfo = NULL; static const CamelType camel_object_type = 1; static CamelType cur_max_type = CAMEL_INVALID_TYPE; @@ -179,15 +180,15 @@ camel_type_init (void) camel_type_lock_up (); if (type_system_initialized) { - g_warning - ("camel_type_init: type system already initialized."); + g_warning ("camel_type_init: type system already initialized."); camel_type_lock_down (); return; } type_system_initialized = TRUE; ctype_to_typeinfo = g_hash_table_new (g_direct_hash, g_direct_equal); - + name_to_typeinfo = g_hash_table_new (g_str_hash, g_str_equal); + obj_info = g_new (CamelTypeInfo, 1); obj_info->self = camel_object_type; obj_info->parent = CAMEL_INVALID_TYPE; @@ -209,7 +210,8 @@ camel_type_init (void) GINT_TO_POINTER (CAMEL_INVALID_TYPE), NULL); g_hash_table_insert (ctype_to_typeinfo, GINT_TO_POINTER (camel_object_type), obj_info); - + g_hash_table_insert (name_to_typeinfo, obj_info->name, obj_info); + /* Sigh. Ugly */ make_global_classfuncs (obj_info); @@ -243,7 +245,14 @@ camel_type_register (CamelType parent, const gchar * name, camel_type_init (); G_LOCK (type_system); } - + + obj_info = g_hash_table_lookup (name_to_typeinfo, name); + if (obj_info != NULL) { + /* looks like we've already registered this type... */ + camel_type_lock_down (); + return obj_info->self; + } + parent_info = g_hash_table_lookup (ctype_to_typeinfo, GINT_TO_POINTER (parent)); @@ -298,6 +307,7 @@ camel_type_register (CamelType parent, const gchar * name, g_hash_table_insert (ctype_to_typeinfo, GINT_TO_POINTER (obj_info->self), obj_info); + g_hash_table_insert (name_to_typeinfo, obj_info->name, obj_info); /* Sigh. Ugly. */ make_global_classfuncs (obj_info); diff --git a/camel/camel-service.c b/camel/camel-service.c index ade9a1d5b2..9c32256fe0 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -260,10 +260,13 @@ camel_service_connect (CamelService *service, CamelException *ex) service->status = ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED; CAMEL_SERVICE_LOCK (service, connect_op_lock); - if (unreg) - camel_operation_unregister (service->connect_op); - camel_operation_unref (service->connect_op); - service->connect_op = NULL; + if (service->connect_op) { + if (unreg) + camel_operation_unregister (service->connect_op); + + camel_operation_unref (service->connect_op); + service->connect_op = NULL; + } CAMEL_SERVICE_UNLOCK (service, connect_op_lock); CAMEL_SERVICE_UNLOCK (service, connect_lock); |