in reply to Re^3: Trying to thread a daemon with threads and Thread::Queue
in thread Trying to thread a daemon with threads and Thread::Queue

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

Replies are listed 'Best First'.
Re^5: Trying to thread a daemon with threads and Thread::Queue
by BrowserUk (Patriarch) on Aug 29, 2008 at 02:32 UTC

    Sorry, but you've posted several versions and partial version of your code in this thread and there is no way for me to guess which version the above is applied to. If you post the full version that demonstrates the problem I will take a look at it.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.