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

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.

Replies are listed 'Best First'.
Re: Re: Re: Re: HTTP::Daemon aborting in send_status_line?
by mifflin (Curate) on Apr 23, 2004 at 06:26 UTC
    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.

        GOOD catch!

        I put a sigpipe handler in and voila!
        no more ugly program aborting

        thanks

        sub send_http_resp { print "$$ begin: send_http_resp\n" if $verbose; my ($client, $content) = @_; local $SIG{PIPE} = sub { print "$$ SIGPIPE\n" }; eval { my $header = HTTP::Headers->new('Content-Type' => 'text/xml; cha +rset=utf-8'); print "$$ send_http_resp : created a new HTTP::Headers object\n" + if $verbose; my $response = HTTP::Response->new(200, 'OK', $header, $content) +; print "$$ send_http_resp : created a new HTTP::Response object\n +" if $verbose; $client->send_response($response); print "$$ send_http_resp OK\n" if $verbose; }; if ($@) { print "$$ caught http exception: $@\n" if $verbose; } print "$$ end: send_http_resp\n" if $verbose; }