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
This commit is contained in:
committed by
Jeffrey Stedfast
parent
e2f8314f13
commit
66587d89a3
@ -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
|
||||
|
||||
@ -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 */
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user