Re: Thread programming question

On Sun, 25 Jun 2000 12:00:17 Matthew Guenther wrote:
> I almost have the mailbox index updating code working 100%, but I have a
> question about the thread setup in balsa (I am totally unfamilar with thread
> programming).  Namely, in libbalsa/mailbox.c:mailbox_check_new the call to
> load_messages is encased in a #ifndef BALSA_USE_THREADS block.  This would
> make sense to me were it not for the LOCK_MAILBOX_RETURN_VAL call at the
> start of the function.  It was my understanding that locking the mailbox
> meant that all other threads wouldn't be able to access it... so why do we
> need the load_messages call blocked out.  Do we?  
> I'm in the middle of testing this now and nothing bad seems to be happening,
> but I've heard many horror stories about the pitfalls of threads so I
> thought I'd check here before making any commits.
> Thanks,

Judging from the CVS comments and changes, it looks like the call is redundant
because the function exits and sends a MSGMAILTHREAD_LOAD to the main thread
while in threaded mode. I'm pretty sure that you can't really rely on the
mailbox locks because these locks are the flock kind, not the mutex kind, so
the other thread could be in the middle of an operation on the mailbox
that it /also/ had a lock.

This is the cvs diff for the relevant lines:;

(ahhh, Bonsai)

Peter Williams /

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