Re: Locking issue



Indeed, I know about these locking problem.

I tried to avoid it, because I usually don't like using recursive locks.

But the solution is to make priv->folder_lock a recursive lock, rather
than a normal one.

If somebody is planning to perform that search/replace, let me know so 
that we'll avoid duplicating work.

ps. I don't really have a good reason for not liking recursive locks.
ps. For people who don't know what a recursive lock is: it's a lock that
can be entered multiple times by the same thread, but while locked can't
be entered by another thread. To unlock it, the thread must unwind all
its enters.

Thread 1:
---------
lock
  lock
    lock
     a += 2;
    unlock
  unlock
unlock

Thread 2:
---------
lock
a -= 2
unlock


On Mon, 2007-02-19 at 16:39 +0100, Sergio Villar Senin wrote:
> Hi,
> 
> playing with message transfers stuff I found a locking issue regarding
> the new folder monitor functionality. I think it's easy to understand
> the locking problem with a backtrace, see how the lock in unload_folder
> creates a deadlock because the folder was previously locked in the call
> to tny_camel_folder_transfer_msgs_async_thread.
> 
> Br.
> 
> #0  unload_folder (priv=0x81eb368, destroy=0) at tny-camel-folder.c:246
> #1  0xb7dfaf8d in tny_camel_folder_uncache (self=0x81eb358) at
> tny-camel-folder.c:1998
> #2  0xb7dfafae in _tny_camel_folder_check_uncache (self=0x81eb358,
> priv=0x81eb368) at tny-camel-folder.c:2008
> #3  0xb7df2e80 in tny_camel_header_finalize (object=0x82b6320) at
> tny-camel-header.c:562
> #4  0xb6e8d1ed in IA__g_object_unref (_object=0x82b6320) at gobject.c:1788
> #5  0xb7b263d8 in destroy_item (item=0x82b6320, user_data=0x0) at
> tny-simple-list.c:141
> #6  0xb6dbf218 in IA__g_list_foreach (list=0xb41027c0, func=0xb7b26358
> <destroy_item>, user_data=0x0)
>     at glist.c:495
> #7  0xb7b26450 in tny_simple_list_finalize (object=0x82b6308) at
> tny-simple-list.c:153
> #8  0xb6e8d1ed in IA__g_object_unref (_object=0x82b6308) at gobject.c:1788
> #9  0xb7b21ed3 in tny_folder_change_finalize (object=0x82722f8) at
> tny-folder-change.c:413
> #10 0xb6e8d1ed in IA__g_object_unref (_object=0x82722f8) at gobject.c:1788
> #11 0xb7df6348 in folder_changed (camel_folder=0x821e5e0,
> info=0xb4104c58, user_data=0x81eb368)
>     at tny-camel-folder.c:197
> #12 0xb7d6996c in camel_object_trigger_event (vo=0x821e5e0,
> name=0xb569ebe3 "folder_changed",
>     event_data=0xb4104c58) at camel-object.c:1424
> #13 0xb568d9e4 in camel_imap_folder_changed (folder=0x821e5e0,
> exists=14, expunged=0x82b6508, ex=0xb4ad732c)
>     at camel-imap-folder.c:3623
> #14 0xb5687858 in imap_rescan (folder=0x821e5e0, exists=14,
> ex=0xb4ad732c) at camel-imap-folder.c:1177
> #15 0xb5686819 in camel_imap_folder_selected (folder=0x821e5e0,
> response=0xb41052a8, ex=0xb4ad732c)
>     at camel-imap-folder.c:618
> #16 0xb5686d07 in imap_refresh_info (folder=0x821e5e0, ex=0xb4ad732c) at
> camel-imap-folder.c:749
> #17 0xb568907e in imap_append_online (folder=0x821e5e0,
> message=0x8277ef8, info=0x82b6948,
>     appended_uid=0xb4104038, ex=0xb4ad732c) at camel-imap-folder.c:1797
> #18 0xb7da087c in disco_append_message (folder=0x821e5e0,
> message=0x8277ef8, info=0x82b6948,
>     appended_uid=0xb4104038, ex=0xb4ad732c) at camel-disco-folder.c:368
> #19 0xb7db2779 in camel_folder_append_message (folder=0x821e5e0,
> message=0x8277ef8, info=0x82b6948,
>     appended_uid=0xb4104038, ex=0xb4ad732c) at camel-folder.c:665
> #20 0xb7db3b7f in transfer_message_to (source=0x821e540, uid=0xb42d60d4
> "9", dest=0x821e5e0,
>     transferred_uid=0xb4104038, delete_original=1, ex=0xb4ad732c) at
> camel-folder.c:1388
> #21 0xb7db3ce0 in transfer_messages_to (source=0x821e540,
> uids=0xb4102710, dest=0x821e5e0,
>     transferred_uids=0xb4ad7328, delete_originals=1, ex=0xb4ad732c) at
> camel-folder.c:1423
> #22 0xb7db3f06 in camel_folder_transfer_messages_to (source=0x821e540,
> uids=0xb4102710, dest=0x821e5e0,
>     transferred_uids=0xb4ad7328, delete_originals=1, ex=0xb4ad732c) at
> camel-folder.c:1474
> #23 0xb7dfa770 in tny_camel_folder_transfer_msgs_default
> (self=0x825b400, headers=0x82a20c0,
>     folder_dst=0x81eb358, delete_originals=1, err=0xb4ad73f4) at
> tny-camel-folder.c:1791
> #24 0xb7dfa367 in tny_camel_folder_transfer_msgs (self=0x825b400,
> headers=0x82a20c0, folder_dst=0x81eb358,
>     delete_originals=1, err=0xb4ad73f4) at tny-camel-folder.c:1732
> #25 0xb7b241c2 in tny_folder_transfer_msgs (self=0x825b400,
> headers=0x82a20c0, folder_dst=0x81eb358,
>     delete_originals=1, err=0xb4ad73f4) at tny-folder.c:536
> #26 0xb7dfa01a in tny_camel_folder_transfer_msgs_async_thread
> (thr_user_data=0x82746f0)
>     at tny-camel-folder.c:1651
> _______________________________________________
> tinymail-devel-list mailing list
> tinymail-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/tinymail-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]