Hi, monks

Some time ago I developed a Windows Service based system for transferring data between servers on our network. All has been running quite nicely now for almost a year, with one glaring exception. About once every two - three months, a thread will fail when attempting to open a file. As a point of context, there are 5 threads performing the work which run non-stop while the server is on (each thread executing the affected lines of code several thousand times per day). The servers are rebooted once a week and the service is only restarted when the reboot occurs.

The error I get is:

Thread 10 terminated abnormally: Failed to open \\server\share\INQUEUE\loadqueue.lck: Invalid argument at service.plx line 596.
The relevant code (lines 595 and 596) are:
my $lockfile = $destDir."loadqueue.lck"; open my $fhLock, ">", $lockfile or die "Failed to open $lockfile: $!" +;

Any suggestions on why this code is failing would be highly appreciated. I guess the obvious work around would be something like this:

my $lockfile = $destDir."loadqueue.lck"; my $fhLock; do { eval { open $fhLock, ">", $lockfile or die "Failed to open $lock +file: $!" } } until (defined $fhLock);
but without understanding why this error might be occurring, I'm a bit wary of doing this.


In reply to Problem opening file by SimonPratt

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.