Changeset 32809


Ignore:
Timestamp:
2019-02-25T16:59:01+13:00 (5 years ago)
Author:
ak19
Message:

Fix to bug that broke OAIDownload tutorial: on Windows, ECONNRESET is not error. This needs to be dealt with in 2 places in WgetDownload.pm, but only once part of the code had the latest version until now. In the remaining spot ECONNRESET was still assumed to be an error even though this happens as a matter of course on Windows. Because of it being dealt with as an error, OAIDownload terminates getting dealing with that oai file before it's actually finished and the gi.Sourcedoc meta no longer ends up in the file. Still another bug remaining in this tutorial.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm

    r32779 r32809  
    716716            $full_text .= $line;
    717717        } else { # error or EOF
    718             if(!defined $len) { # error reading
    719             #print STDERR "WgetDownload: Error reading from child stream: $!\n";
    720             $error = 1;
    721             }
    722              if(!defined $len) {
     718             if(!defined $len) { # could be an error reading   
     719              # On Windows, the socket ends up forcibly closed on the "other" side. It's just the way it's implemented
     720              # on Windows when using sockets to our child process' iostreams. So $len not being defined is not an error in that case. Refer to
     721              # https://stackoverflow.com/questions/16675950/perl-select-returning-undef-on-sysread-when-using-windows-ipcopen3-and-ios/16676271
    723722              if(!$!{ECONNRESET}) { # anything other ECONNRESET error means it's a real case of undefined $len being an error
    724                 #print STDERR "WgetDownload: Error reading from child stream: $!\n";               
     723                print STDERR "WgetDownload: Error reading from child stream: $!\n";
     724                # SHOULD THIS 'die "errmsg";' instead? - no, sockets may need closing
    725725                $error = 1;
    726               } else { # the error code is ECONNRESET, and it's not an error, despite $len being undefined.
    727                        # Happens on Windows when using sockets to a child process' iostreams
     726              } else { # $! contains message "An existing connection was forcibly closed by remote host" where "remote" is a reference to the sockets to our wget child process,
     727                    # NOT to the remote web server we're downloading from. In such a case, the error code is ECONNRESET, and it's not an error, despite $len being undefined.
     728                    # Happens on Windows when using sockets to a child process' iostreams
    728729                #print STDERR "WgetDownload: wget finished\n";
    729730              }
Note: See TracChangeset for help on using the changeset viewer.