Re: Re[2]: MailBox development impuls

Mark Overmeer <[email protected]> Fri, 30 Jul 2004 11:21:08 +0200
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Wiggins d Anconia ([email protected]) [040727 15:43]:
> If the code forks you may be experiencing the same thing I mentioned
> back in 11/2003.
> 
> http://marc.theaimsgroup.com/?l=perl-mailbox&m=106796841320810&w=2

I am always trying to answer to all problems... if I do not answer, it
means the message was lost... with the amount of spam and other stuff I
get in my mailbox, it sometimes happens that I accidentally remove
something I should read, so please push them again after a few days...

Your discription of the problem is quite clear: in some situations,
MailBox can create non-unique message-IDs.  On the moment, when MailBox
is started, it takes 'time'. and then increments this each time a
new ID is needed.  But when you play with forks within MailBox, that
is not sufficient: the unique value will not get incremented over all
threads and may cause collisions.

You suggest to Time::HiRes as message id.  My problem with that, is
that it requires a system-call for each id created.  In the current
solution, it is only one "time" per program.  However, adding a
random value will probably call the system as well... and is even
less safe.

Time::HiRes... needs a fallback for systems where it is not
installed/available....

Ok,... it was not that easy, but I have implemented a new numbering
scheme for the next release:

  Mail::Message::Head::Complete->messageIdPrefix(...OPTIONS...)

now can have a
  PREFIX   string  (defaults to mailbox-$$)
  HOSTNAME string  (defaults to Sys::Hostname || localhost)
inbetween, Time::Hires::gettimeofdat is used when available, otherwise
the current unique_id++

You may also specify your own
  CODE-ref

I have tested all three... will be in the next release.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net