Changeset 31956 for main/trunk/greenstone2/perllib/downloaders
- Timestamp:
- 2017-09-08T19:08:40+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm
r31929 r31956 295 295 local (*TO_CHLD_R, *TO_CHLD_W); 296 296 local (*FR_CHLD_R, *FR_CHLD_W); 297 local (*FR_CHLD_ERR_R, *FR_CHLD_ERR_W);297 #local (*FR_CHLD_ERR_R, *FR_CHLD_ERR_W); 298 298 299 299 if ($^O =~ /Win32/) { … … 311 311 # see http://blog.0x1fff.com/2009/09/howto-execute-system-commands-in-perl.html 312 312 313 return ( $pid, *TO_CHLD_W, *FR_CHLD_R, *FR_CHLD_ERR_R ); 313 #return ( $pid, *TO_CHLD_W, *FR_CHLD_R, *FR_CHLD_ERR_R ); 314 return ( $pid, *TO_CHLD_W, *FR_CHLD_R); 314 315 } 315 316 … … 457 458 else { # error or EOF: (!defined $len || $len == 0) 458 459 459 if(!defined $len) { # error reading 460 print STDERR "WgetDownload: Error reading from child stream: $!\n"; 461 # SHOULD THIS 'die "errmsg";' instead? - no, sockets may need closing 462 $error = 1; 463 } 464 elsif ($len == 0) { # EOF 465 # Finished reading from this filehand $fh because we read 0 bytes. 460 if(!defined $len) { # could be an error reading 461 # On Windows, the socket ends up forcibly closed on the "other" side. It's just the way it's implemented 462 # on Windows when using sockets to our child process' iostreams. So $len not being defined is not an error in that case. Refer to 463 # https://stackoverflow.com/questions/16675950/perl-select-returning-undef-on-sysread-when-using-windows-ipcopen3-and-ios/16676271 464 if(!$!{ECONNRESET}) { # anything other ECONNRESET error means it's a real case of undefined $len being an error 465 print STDERR "WgetDownload: Error reading from child stream: $!\n"; 466 # SHOULD THIS 'die "errmsg";' instead? - no, sockets may need closing 467 $error = 1; 468 } 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, 469 # 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. 470 print STDERR "WgetDownload: wget finished\n"; 471 } 472 } 473 elsif ($len == 0) { # EOF 474 # Finished reading from this filehandle $fh because we read 0 bytes. 466 475 # wget finished, terminate naturally 467 476 print STDERR "WgetDownload: wget finished\n"; … … 694 703 $error = 1; 695 704 } 705 if(!defined $len) { 706 if(!$!{ECONNRESET}) { # anything other ECONNRESET error means it's a real case of undefined $len being an error 707 #print STDERR "WgetDownload: Error reading from child stream: $!\n"; 708 $error = 1; 709 } else { # the error code is ECONNRESET, and it's not an error, despite $len being undefined. 710 # Happens on Windows when using sockets to a child process' iostreams 711 #print STDERR "WgetDownload: wget finished\n"; 712 } 713 } 696 714 elsif ($len == 0) { # EOF, finished with this filehandle because 0 bytes read 697 715 #print STDERR "WgetDownload: wget finished\n"; # wget terminated naturally
Note:
See TracChangeset
for help on using the changeset viewer.