I've moved this back from the deeply-nested sub-thread and quote your /msgs below for clarity.

The API response determines if the MAC is a "known" MAC. We then allow it to RADUIS auth. After RADIUS auth, the MAC is allowed into a network .

Another http service reports idle MACs based on n/w packets. I delete them from %clients forcing them to do API / RAdius Auth again.

Basically we continously allow MACs to come into the n/w , auth them in hte background and drop when no activity is seen

If I read that correctly, you retain the %client hash of MACs so that you can avoid re-authing them if they are already authed.

And you need to query another server that tracks MAC activity by inspecting packets.

And when that other server replies:"this MAC has been inactive for a while"

You delete that MAC from the %clients hash so the next time it turns up in the logs, it has to re-authorise.


If the above is a true reflection of the process, then I would suggest the following modification to the process to avoid having to constantly poll the Auth server with every known MAC.

The file reading loop remains the same:

while( <LOG> ) { next unless m[ACK (...)]i; async( \&checkMAC, $1 )->detach; }

But the logic in checkMAC() gets modified:

sub checkMAC{ my $mac = shift; ## If this is a known MAC & it has previously authorised successfu +lly if( exists $clients{ $mac } and $clients{ $mac } ) { ## Check with the activity monitor to see if it has fallen ina +ctive my $active = get "http://activityServer/check.pl?mac=$mac"; ## If is has never fallen inactive, it is known, authorised, a +nd active ## and there is nothing to do return if $active; ## Not sure that this is really necessary, ## but it might save a little resource. lock %clients; delete $clients{ $mac }; } ## Otherwise, check http & Auth and modify status (or add) in %cli +ents my $httpRes = get ...; my $authRes = get ...; lock %clients; $clients{ $mac } = $httpRes && $authRes ? 1 : 0; return. }

This way, you'd only contact the activity server each time a MAC appears in the log, rather than constant having to poll it for every known MAC.


In reply to Re: Should I use threads? Perl/DHCP/Radius by BrowserUk
in thread Should I use threads? Perl/DHCP/Radius by Anonymous 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.