Re: A few remarks about locking



On 2002.03.26 13:44 Emmanuel wrote:
> On 26.03.2002 09:42 Pawel Salek wrote:
>> On 2002.03.25 16:54 Emmanuel wrote:
>>> It's written in a comment before the function 
>>> libbalsa_mailbox_load_messages(LibBalsaMailbox * mailbox) (in 
>>> libbalsa/mailbox.c) that it must be called with the gdk lock held. 
>>> But I think it's false. In fact I even try it without the gdk lock 
>>> and it works perfectly. I think that it is because we don't use any 
>>> UI function (we only emit signals and process the libmutt headers).
>> 
>> Just remember that the signal handlers may call GDK functions.
> 
> Yes you're right.
> But if you look at libbalsa_mailbox_load_messages, the big loop does 
> not call gtk (AFAICS) so we could release the lock before it and 
> reclaim it after. I think this improves a bit the UI interactivity 
> for huge mailboxes.

One must be *extremely* careful. nested locks must always acquired in 
same order (see HACKING). Otherwise, it easy to deadlock. Possible 
scenario: mailbox lock is held by a thread, gdk lock is released. The 
other thread gets GDK lock and waits for mailbox lock. The first thread 
tries to get GDK lock back, and we have a deadlock.

-pawel



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