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

tried the handleData() sub you suggested. Exhibits teh same exact problem as the one I described above... It was probably one of the very first versions I tried of that sub :/

The socket doesn't receive anything, hangs, until on the client connect side I CTRL+C, then the server log would show just one log message "(3) : Connection from: x.x.x.x", and the server immediately dies with no errors/warnings right after.

I will try IO::Socket, it's something I've been meaning to do.. Perhaps two different variations, one script as you describe, and another with threads and threads::shared, kind of like the 4th point discussed on this thread:
Re: Passing an IO:Handle to a Thread

My main concern behind the limitation of handling one connection at a time is the possibility of a really slow (or dysfunctional) client that takes too long to send its request (or doesn't send a request at all) after it connects to the server, making all other incoming connections queued as long as the connected (slow/dysfunctional) client has not timed out.

  • Comment on Re^4: Trying to thread a daemon with threads and Thread::Queue

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

    Sorry, I don't think I can help further. Your code with that change works for me here. I have stayed with (actually reverted to) 5.8.6 because I've had all kinds of unresolvable problems using threads with 5.8.8. Too many changes have been made for change sake. The once pretty reliable techniques I used successfully since 5.8.0 stop working. The current maintainer has his own agenda, which from my perspective comes down to complexity for its own sake.


    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.
      Strange... The server I am testing on is running perl 5.8.5 Anyways, I think I might just try without Thread::Queue completely, perhaps just threads and threads::shared.
      A thought that comes to mind, is to keep the connection threads alive for a pre-defined number of connections, say $threadLifeTime = 100.

      I'll do some more reading and research to see if I can do without Thread::Queue.