Dear monks,

As someone new to threads, I got a lot of help from here (and the resident expert) and now have a working model. The original post is here:

Should I use threads? Perl/DHCP/Radius

To summarize: 3 threads exist. One thread reads log files for IP leases and parses MAC. The parsed MAC is used to spawn a new thread with checks a server and when the server sends a HTTP 200 OK, does a authentication calling the localhost and the thread detaches. The 3rd thread simply talks to the localhost to check which MACs are connected and holds/deletes them in a hash which all 3 threads share.

Some other issues related to 5.8.4 version were posted here: Perl5.8.4 , threads - Killing the "async" kid

I have since made two deployments and things are working satisfactorily. The daemon is part of the system start up sequence. All parts of the code seemed to have been proven.

There is however, one irritant though. The daemon dies sometimes forcing me to manually restart it. This has no pattern. Sometimes it dies in a few minutes, sometimes few hours and sometimes it runs until the system is restarted again (24hour cycle).

I tried the following:

  • Enclosed all the threads in eval blocks and printing the $@ to my log file as suggested in Programming Perl.
  • Put signal handlers and logging it to my log file
  • Started the daemon from terminal with
    >> lease.log 2>&1 &
    appended at the end.
  • None of them have written anything at all to the log file when the daemon dies unexpectedly . I repeat that there is no pattern here.

    Any suggestions on how to get it to log something before it dies? Personally, I am looking at writing a wrapper around the daemon which checks its status one in a while. Has anyone done anything like this before? I am looking for advice in general. Please note: upgrade kernel, Perl not possible at all. I have looked into everything, strengthened the code with locks , ensured clean variable usage etc. Still the murderer (and the motives) are unknown, making me sleepless.


    In reply to Coroner not helping - Perl5.8.4,threadsv1.03 and the case of myterious deaths by MonkeyMonk

    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.