I found an implict multithread problem. I want to see
whether anybody could give me more information about it.

In function message-list.c:mail_regen_list,
a new message is created and put into a thread queue,
meanwhile, the message is also prepended to a regen list of the message
But, the regen list is not protected by a mutex which maybe lead to a
severe problem because
it will be changed in thread function "regen_list_free" and
is this a bug of evolution?

/* if we're busy already kick off timeout processing, so normal updates
are immediate */
        if (ml->regen == NULL)
the new message is put into a thread queue
        else {
                ml->regen_timeout_msg = m;
                ml->regen_timeout_id = g_timeout_add(500,
(GSourceFunc)ml_regen_timeout, m);

static gboolean
ml_regen_timeout(struct _regen_list_msg *m)
        e_profile_event_emit("list.regenerate", m->folder->full_name,

        This code is not protected
        m->ml->regen = g_list_prepend(m->ml->regen, m);                 
        /* TODO: we should manage our own thread stuff, would make
cancelling outstanding stuff easier */
        e_thread_put (mail_thread_queued, (EMsg *)m);

        m->ml->regen_timeout_msg = NULL;
        m->ml->regen_timeout_id = 0;

        return FALSE;

regen_list_free (struct _mail_msg *mm)
        struct _regen_list_msg *m = (struct _regen_list_msg *)mm;
        int i;

        e_profile_event_emit("list.regenerated", m->folder->full_name,

        if (m->summary) {
                for (i = 0; i < m->summary->len; i++)
                        camel_folder_free_message_info (m->folder,
                g_ptr_array_free (m->summary, TRUE);

        if (m->tree)
                camel_folder_thread_messages_unref (m->tree);

        g_free (m->search);
        g_free (m->hideexpr);

        camel_object_unref (m->folder);

        if (m->changes)
                camel_folder_change_info_free (m->changes);

        /* we have to poke this here as well since we might've been
cancelled and regened wont get called */
        This code is not protected
        m->ml->regen = g_list_remove(m->ml->regen, m);


Jeff Cai

Evolution-hackers mailing list

Reply via email to