bug-mailutils
[Top][All Lists]
Advanced

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

Re: POP3d locking


From: Alain Magloire
Subject: Re: POP3d locking
Date: Tue, 24 Apr 2001 14:49:00 -0400 (EDT)

> 
> > So my proposition:
> > - lock the mailbox the entire session: i.e the lock
> >   is only advisory %.lock not fcntl (F_LCK )
> > - Check in the TRANSACTION stage for corruption
> >   some program may not respect the lock.
> > - update the lock (touchlock) .. touch the file %.lock
> > - unlock the mailbox rm %.lock at the end of the session.
> > 
> > Thoughts?
> Sounds very good. Would you mind if I try to implement this?

OK, I'm leaving and will not be back 'till Monday.
Please do not hesitate to send mail to the list.  I will get
updated on Monday.

1- And Many thanks, for taking the time to test the lib and applications.
The exchange was very usefull (Merci beacoup).

2- You did not get some proper credits in ChangeLog for certain patch
Will Correct that when I come back.

3- Few notes:

- the code in mailutils/mailbox/locker.c:
  should probably be revisited.  I'll do that later.

My sugestion now would be to create a pop3d_lock()
pop3d_unlock(), pop3d_touchlock().  Before doing the

pop3d_lock()
mailbox_open()

and on exit; pop3d_unlock ()

The original idea/plan was this: we have a function call
mailbox_set_locker () so after creating the mailbox, an application
could set on the mailbox, is special locker_t object that
would be use for locking.  So:

{
  locker_t poplock = NULL:
  pop3d_lock_create ( &poplock );

  mailbox_create (&mbox, "/var/mail/sparky");
  mailbox_set_locker (mbox, poplock);
  mailbox_open (mbox, MU_STREAM_RDWR);
  ....
  mailbox_close (mbox);
  mailbox_destroy (&mbox);
}

int
pop3d_lock_create (locker_t *l)
{
  struct poplocker_t *pl;
  // initialize structure ...
  locker_create (l, pl);
  locker_set_lock (l, pop3d_lock, pl);
  locker_set_unlock (l, pop3d_unlock, pl);
  locker_set_touchlock (l, pop3d_touchlock, pl);
  return 0;
}

int
pop3d_lock (locker_t,...)
{
  // Noop if we already have the lock or implement a counter 
}

int
pop3d_unlock (locker_t, ...)
{
  // when counter reach 0, delete file.
}

4- But unfortunately I did not have time to code the
  locker_set_xxx() overload functions 8-(. Nor finish
  locker.c(Originaly written by Brian Edmond) to not have
  race conditions on NFS mounted spoolmails.

5- Jakob (Sparky) had pointed to me to library call
  liblockfile.  That, according to him, handle race conditions
  properly.


Ok, enough said,  Talk to you monday.

-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on n'est toujours assis que sur son cul !!!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]