Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Net-HTTP 6.06 intermittent death in Net::HTTP::Methods sub my_readline() (solved) [rt.cpan.org #86448]

Aperta
#28 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
perl
Ambito
networking

Direzione di ricerca

Esamina Net/HTTP/Methods.pm, concentrandoti sull’entry point my_readline() e sul malfunzionamento segnalato alla riga 265. Confronta la patch fornita con il comportamento di SSL_WANT_READ e SSL_WANT_WRITE descritto nell’issue. Il lavoro è completato quando le letture HTTPS intermittenti non terminano più con un errore quando IO::Socket::SSL richiede prima un’altra lettura o scrittura.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Migrated from rt.cpan.org#86448 (status was 'new')

Requestors:

From [email protected] on 2013-06-26 15:46:52:

Description:

Net::HTTP::Methods from Net-HTTP 6.06 dies intermittently with:

Status read failed: No such file or directory at …/perl/vendor/lib/Net/HTTP/Methods.pm line 265.


Cause:

IO::Socket::SSL object can reject the read request with an error of either "SSL wants a read first" or "SSL wants a write first."  This is apparently some overhead of SSL where it wants a read/write before allowing you to read/write in some cases.  It's described somewhat (but not much) better under errstr() in the latest IO::Socket::SSL perldoc.


Reproducing:

I'm not sure how hard this is to reproduce since triggers are unknown.  I'm accessing cloud based SOAP via SOAP::WSDL over https from a busy server and it occurs maybe one out of a dozen times.  It seems to correlate with SSL taking an extra bit of time to setup the connection when something in the chain is busier or has a little latency.  Thus far, I've only seen SSL_WANT_READ, and it clears immediately on the next redo READ, but there seems to be no harm in preparing for SSL_WANT_WRITE in the patch as well.


Patch:

--- broken/Net/HTTP/Methods.pm    2013-03-10 23:35:42.000000000 -0500
+++ fixed/Net/HTTP/Methods.pm 2013-06-26 10:12:37.205639200 -0500
@@ -243,40 +243,41 @@
 sub my_readline {
     my $self = shift;
     my $what = shift;
     for (${*$self}{'http_buf'}) {
        my $max_line_length = ${*$self}{'http_max_line_length'};
        my $pos;
        while (1) {
            # find line ending
            $pos = index($_, "\012");
            last if $pos >= 0;
            die "$what line too long (limit is $max_line_length)"
                if $max_line_length && length($_) > $max_line_length;

            # need to read more data to find a line ending
           READ:
             {
                 die "read timeout" unless $self->can_read;
                 my $n = $self->sysread($_, 1024, length);
                 unless (defined $n) {
                     redo READ if $!{EINTR} || $!{EAGAIN};
+                    redo READ if ( $self->isa('IO::Socket::SSL') && $self->errstr() =~ /^SSL wants a (?:read|write) first$/ );
                     # if we have already accumulated some data let's at least
                     # return that as a line
                     die "$what read failed: $!" unless length;
                 }
                 unless ($n) {
                     return undef unless length;
                     return substr($_, 0, length, "");
                 }
             }
        }
        die "$what line too long ($pos; limit is $max_line_length)"
            if $max_line_length && $pos > $max_line_length;

        my $line = substr($_, 0, $pos+1, "");
        $line =~ s/(\015?\012)\z// || die "Assert";
        return wantarray ? ($line, $1) : $line;
     }
 }


Thanks for your time and your code.

--

Raymond Ferguson

Integrated Applications Engineer  | CDW

Lingua principale
Perl
Stelle
20
Fork
27
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di libwww-perl/Net-HTTP

Tutte le issue di libwww-perl/Net-HTTP

Issue simili

Altre issue su Perl

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.