Hi. Was out of action for a few days owing to sickness. Thanks for the tips. I smacked by forehead for not setting up warnings. ( I thought I had ) I do not know what happened after that. I was so fed up of the daemon dying that I just decided to look into the most tricky part. Consider this code which is part of one of the spawned threads

iprint " MAC: $mac : Contacting API......\n" if $debug > 1; # Wrap call to API with eval eval { local $SIG{ALRM} = sub { iprint "Network Delay) alarm ( $maxNetworkDelay) ; $ua = LWP::UserAgent->new( timeout => $maxNetworkDelay); $response = $ua->request( HTTP::Request->new(GET => $AuthURL +forMAC.$mac)); $respcon = $response->content; alarm(0); }; iprint " MAC: $mac $@" if $@;

( I know you had mentioned earlier that LWP::Simple would do the job but then I needed to look specifically into the RC codes in the response which LWP::Simple does not support.) 2 threads use the above code for 2 different URLS and the response is looked into for further course of action

I initially thought that the ALRM signal would be trapped in the eval block and the local signal handler would do the job. Apparently, the $maxNetworkDelay was being triggered when network delays occurs and that actually sends a signal to all threads. This was causing the death of the daemon.

By simply adding a $SIG{ALRM} = sub { return;) at the very top of the daemon before any thread definition I was able to recover. So when the ALRM is triggered all threads receieve them and return back to the state they were in earlier. MOdified code below with $SIG{ALRM} handler defined as common for all threads and local handler removed.

iprint " MAC: $mac : Contacting API......\n" if $debug > 1; # Wrap call to API with eval eval { $ua = LWP::UserAgent->new( timeout => $maxNetworkDelay); $response = $ua->request( HTTP::Request->new(GET => $AuthURL +forMAC.$mac)); $respcon = $response->content; }; iprint " MAC: $mac $@" if $@;

For the first time the daemon has run for 2 days without a problem. Did I know why I wrote the handler at the top? Partly yes, because I knew all threads were getting the signals in 5.8.4.

Do I know what is happening precisely? Definately not. Would appreciate your views on this


In reply to Re^2: Coroner not helping - Perl5.8.4,threadsv1.03 and the case of myterious deaths by MonkeyMonk
in thread 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.