In an attempt to trace the problem, I modified my code a bit for the sub handleData()

Here is the relative lines from the sub:
my $tid = threads->tid(); my $fno = $Q->dequeue(); last if $fno eq 'STOP'; $log->warning("Thread ($tid) : fileno: $fno"); open my $socket, '+<&='.$fno or dienice("Thread ($tid) could not reope +n socket: $!");

When I try to connect from client side, I see this in the server log:
Thread (1) : fileno: 5 Thread (1) could not reopen socket: Bad file descriptor at line 152
Which is the "open my $socket, '+<&='.$fno" Line..
If I try connecting again, the fileno is still 5, only the thread number changes (1..3 when running only 3 listener threads) and each thread is "terminated abnormally" due to this error.

Other instance, I get this in the log (both lines returned on one connection only)
Thread (2) : fileno: ÆD²©ê Thread (3) : fileno: 5
Or this:
Thread (1) : fileno: 5 Thread (2) : fileno: ÆýD²©ê
And the client gets nothing back to its request.

Running:
Perl 5.8.5 and Thread::Queue 2.11
OS: Linux

In reply to Re^4: Trying to thread a daemon with threads and Thread::Queue by jasmineaura
in thread Trying to thread a daemon with threads and Thread::Queue by jasmineaura

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.