Camel calls causing hangs?

View: New views
2 Messages — Rating Filter:   Alert me  

Camel calls causing hangs?

by Filipe Nepomuceno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey all,


My plugin is hanging and I dont know why. I created a new thread using
a GThread and g_thread_create.
In the new thread I have all my camel calls. (I assume this is what
you guys mean when you say dont
have camel calls in the main thread).

Are the camel calls allowed to be called like below? I managed to get
a GPtrArray of folders but I
think it hangs after that when I try to get the messages.

I realise I shouldnt be trying to get all the messages but I'm trying
it on a small mailbox just to
get some working code and then I'll optimize it later (if I get there).

Well this is where I think it's hanging:

gpointer pimp_mail_process_mail(gpointer data)
{
        GPtrArray* stores = (GPtrArray*) data;
        GPtrArray* folders = g_ptr_array_new();
        GPtrArray* messages = g_ptr_array_new();
        int i, j;
       
        for(i = 0; i < stores->len; i++)
        {
                CamelStore* store = (CamelStore*) g_ptr_array_index(stores, i);
                CamelFolderInfo* info = camel_store_get_folder_info(store , NULL,
                                                                CAMEL_STORE_FOLDER_INFO_SUBSCRIBED | CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL,
                                                                NULL);
               
                if(info != NULL)
                {
                        //get top of directory
                        while(info->parent != NULL)
                                info = info->parent;
                       
                        //gets list of folders - works till here
                        pimp_mail_process_folderinfo(store, info, &folders);
                }
        }
       

        //it hangs in this loop - WHY????
        for(i = 0; i < folders->len; i++)
        {
                CamelFolder* folder = (CamelFolder*) g_ptr_array_index(folders, i);
                GPtrArray* uids = camel_folder_get_uids(folder);

                for(j = 0; j < uids->len; i++)
                {
                        CamelMimeMessage* message = camel_folder_get_message(folder, (const
char*) g_ptr_array_index(uids, j), NULL);
                       
                        if(message != NULL)
                                g_ptr_array_add(messages, message);
                }
        }
       
        //do stuff with messages here
       
        g_ptr_array_free(messages);
        g_ptr_array_free(folders);
        g_ptr_array_free(stores);
       
        return 0;
}
_______________________________________________
Evolution-hackers mailing list
Evolution-hackers@...
http://mail.gnome.org/mailman/listinfo/evolution-hackers

Re: Camel calls causing hangs?

by Milan Crha :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2009-06-23 at 22:43 +0200, Filipe Nepomuceno wrote:
>            for(j = 0; j < uids->len; i++)
                                      ^^^ use 'j' here?

Try to differentiate between "hang" and "busy loop", there is a little
difference between them :)

Also, those returned CamelObjects are supposed to be unreffed too, not
just free your array. Even I cannot tell you from this code part, as
it's not complete. (Those mail-ops functions I pointed you earlier are
unreffing arguments itself, at the end, thus in the best you should ref
them, and when done with them unref them. There is no reffing necessary
when you use it in the "done" callback only, but when you left the
callback and still need the pointer, then there should be a ref and
unref done. Just to ensure you'll not lose the pointer before you are
done with it. I think. Check the code where those are used in
evolution.)
        Bye,
        Milan

_______________________________________________
Evolution-hackers mailing list
Evolution-hackers@...
http://mail.gnome.org/mailman/listinfo/evolution-hackers