in reply to HTTP::Daemon aborting in send_status_line?

The print statement is probably blocking. One reason for that could be that the socket went away and you were told by the failure of a system call, but you didn't handle the error. Can you reproduce this problem with the small sample server that comes with HTTP::Daemon? (I wasn't able to) Can you try to whittle your program down to the smallest section that demonstrates the problem and post that?

In particular, it looks like this might be the effect you'd see if you didn't check the return status from the get_request method.

Replies are listed 'Best First'.
Re: Re: HTTP::Daemon aborting in send_status_line?
by mifflin (Curate) on Apr 23, 2004 at 03:24 UTC
    I thought I did just that.
    That sub in my original post is in HTTP::Daemon::ClientConn
    How would check the return status of a print statement?

    update

    I've even tried putting in an eval block directly in that sub like...

    sub send_status_line { my($self, $status, $message, $proto) = @_; return if $self->antique_client; $status ||= RC_OK; $message ||= status_message($status) || ""; $proto ||= $HTTP::Daemon::PROTO || "HTTP/1.1"; print STDOUT "$$ ",__PACKAGE__,"::send_status_line before print\n" +; eval { print $self "$proto $status $message$CRLF"; }; if ($@) { print STDOUT "$$ ",__PACKAGE__,"::send_status_line caught excep +tion $@\n"; } print STDOUT "$$ ",__PACKAGE__,"::send_status_line after print\n"; }

    but that line never prints either

      Well, you can check the return value from print just like anything else:

      print "hello there\n" or die "print failed: $!\n";

      It's possible, though, that the print statement isn't failing, but is just blocking, waiting for the socket to become writable. Since this will never happen, it will wait forever.

      Whether this is happening will depend on the state of the socket when send_status_line is entered, so you'll need to show us more code---ideally, the smallest amount of code that still exhibits the error.

        I'll post some more tomorrow when I get in to work.
        As far as the 'blocking' goes I don't see how that can be. The program does not hang (block) on the print statement, it stops at it (dies without raising an exception).
        I'll also try putting the client file handle on a select and see if it can_write.