shotgunefx has asked for the wisdom of the Perl Monks concerning the following question:

I've run into a strange problem with a forking daemon I've written. It uses HTTP::Daemon.

The daemon code has been running stable for well over a year. I wanted to move it to another linux machine and I've run into an odd problem.

On the new system, the daemon won't answer a request until another request comes. The daemon is fairly involved and breaking out a minimum case example might take a bit.

I've compared the output from the two demons and it given the same request, the server responds with the same content byte-wise. This hanging does not happen when I telnet in and type the request manually. I thought it might be an LWP issue (That's what I was using to make the requests) but lynx is doing the same thing.

Anyone have an idea on what could possibly cause this behaviour to narrow where I should start looking? It would be greatly appreciated.

-Lee

"To be civilized is to deny one's nature."
  • Comment on Daemon won't process request until next

Replies are listed 'Best First'.
Re: Daemon won't process request until next
by jsprat (Curate) on Jul 16, 2003 at 20:44 UTC
    You may want to try LWP::Debug with each of the servers to see what's different (if anything) between the connections.

    BTW, which version(s) of perl, LWP, and HTTP::Daemon (+ any other modules) are you using? Are they the same versions on the new server as the old server? If you replace one at a time, how does it affect the problem?

    HTH...

Re: Daemon won't process request until next
by sgifford (Prior) on Jul 16, 2003 at 20:23 UTC

    I would debug this either with the Perl debugger, by inserting a lot of print statements and seeing where the daemon is getting stuck, or else with strace.

    I know that's rather obvious and perhaps unhelpful, but without any details whatsoever the only other option is wild guessing...

      Nothing wrong with stating the obvious. I tried the print route. I compared the output of the manually typed telnet request and the lynx/lwp requests and they all have the same exact byte per byte, input and output.

      Basically get_request() is not seeing the last line of the request until another request comes in.I think it's an IO::Handle thing. The machine with the problem was just for testing. I've run it on other machines since without problems so probably some deep crusty socket problem. Maybe a bad header or something. Either way I just gave up as the test machine is about to get it's OS replaced.

      -Lee

      "To be civilized is to deny one's nature."
Re: Daemon won't process request until next
by Thelonius (Priest) on Jul 16, 2003 at 19:50 UTC
    Well autoflushing is on by default. It seems like there might be a bug in get_request. I'm fairly confounded here.
    Flushing is not enough. You must close your handles. Your response is not over until the socket is closed. That's how HTTP works.
      ...assuming you're not using keep-alive.
      I am aware of this. Indeed the socket is getting closed. It seems to be a bug in HTTP::Daemon or one of the socket libraries as I have now tried it on 3 other machines without problems. Only this one machine. F**king hate problems like this, sigh.

      Thanks,
      -Lee

      "To be civilized is to deny one's nature."
        Do your versions of perl or HTTP::Daemon differ on this box?

        -Waswas
Re: Daemon won't process request until next
by Aristotle (Chancellor) on Jul 16, 2003 at 18:27 UTC
    I don't have any idea what I'm talking about, but the symptoms do sound like some sort of buffering issue. Make sure you close/flush any handles ASAP?

    Makeshifts last the longest.

      Well autoflushing is on by default. It seems like there might be a bug in get_request. I'm fairly confounded here.

      -Lee

      "To be civilized is to deny one's nature."