in reply to Re: HTTP::Daemon aborting in send_status_line?
in thread HTTP::Daemon aborting in send_status_line?

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

Replies are listed 'Best First'.
Re: Re: Re: HTTP::Daemon aborting in send_status_line?
by sgifford (Prior) on Apr 23, 2004 at 05:25 UTC

    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.
        The program does not hang (block) on the print statement, it stops at it (dies without raising an exception).
        Perhaps you're getting a "broken pipe" exception. Quote from Lincoln Stein's book "Network Programming in Perl":
        The PIPE signal is sent when a program writes to a pipe or socket but the process at the remote end has either exited or closed the pipe.

        Try setting a $SIG{PIPE} handler to an error reporting sub.