This simplified (and retested :) ) perl script is basically a thread-pooled tcp server. Think of it like how apache traditionally does things, but in perl, with threads, and not serving http. It starts up a pool of threads which try to accept() connections on a tcp socket, and manages them with some parameters to control the maximum number of threads, minimum idle threads, maximum idle threads, and maximum connections per thread before it recycles itself.

The problem I'm having is that as soon as a thread exits (recycles self after receiving RCVR_MAXCON connections), I start getting error messages of the form:

Attempt to free unreferenced scalar at /usr/lib/perl5/5.8.1/i586-linux-thread-multi/IO/Socket.pm line 46.

That part of IO::Socket is the line containting delete $arg{Timeout} in the new() function:

sub new { my($class,%arg) = @_; my $sock = $class->SUPER::new(); $sock->autoflush(1); ${*$sock}{'io_socket_timeout'} = delete $arg{Timeout}; return scalar(%arg) ? $sock->configure(\%arg) : $sock; }
Any thoughts on what I'm doing wrong with the socket to generate these warnings? Other than the warnings themselves, the code seems to work as it's supposed to. (example scripts themselves moved to a comment below)

In reply to Problems with a thread-pooled tcp server by ph713

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.