Wise monks,

When I took over legacy POP3 mail processing production code years ago, it had a number of bugs to fix. Not having much time to do it, I fixed some of the bugs as time permitted.

A serious bug that's a bit over my head is when concurrent POP3-clients try to delete the same mail message using Mail::POP3Client -
each client would first fetch the mail at $id, read the headers to see if the message-id is the right one, then delete it on the POP3 server.
Imagine two clients trying to do that with the same message - each would fetch it, find it to be the right one and send the delete request. Add a little network latency and two different messages would be deleted.

I guess I am looking for a kind of file/Flock way to allow only one client at a time to prepare and execute a deletion, having the others wait until it has finished.
But I am certain, other people will have had the same problem before me and may have got better solutions. Could you point me towards it?

Cheers, Sören


In reply to Locking a POP3 Mailbox by Happy-the-monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.