Re: A few remarks about locking

On Tue, Mar 26, 2002 at 09:35:33PM +0100, Pawel Salek wrote:
> 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.

in this particular:

libbalsa_mailbox_load_messages(LibBalsaMailbox * mailbox)
    if (CLIENT_CONTEXT_CLOSED(mailbox))

+	gdk_threads_leave();

    for (msgno = mailbox->messages; mailbox->new_messages > 0; msgno++) {
	cur = CLIENT_CONTEXT(mailbox)->hdrs[msgno];

+	gdk_threads_enter();

			libbalsa_mailbox_signals[MESSAGES_NEW], messages);

doesn't seem particularly evil

Carlos Morgado - chbm(at)chbm(dot)nu - -- gpgkey: 0x1FC57F0A FP:0A27 35D3 C448 3641 0573 6876 2A37 4BB2 1FC5 7F0A
I am Homer of Borg! Prepare to be... OOooo! donuts! 

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