+ print("started $type dump, pid=$xferPid, tarPid=$tarPid,"
+ . " share=$shareName\n");
+
+ if ( $useTar || $xferPid > 0 ) {
+ #
+ # Parse the output of the transfer program and BackupPC_tarExtract
+ # while they run. Since we might be reading from two or more children
+ # we use a select.
+ #
+ my($FDread, $tarOut, $mesg);
+ vec($FDread, fileno(TAR), 1) = 1 if ( $useTar );
+ $xfer->setSelectMask(\$FDread);
+
+ SCAN: while ( 1 ) {
+ my $ein = $FDread;
+ last if ( $FDread =~ /^\0*$/ );
+ select(my $rout = $FDread, undef, $ein, undef);
+ if ( $useTar ) {
+ if ( vec($rout, fileno(TAR), 1) ) {
+ if ( sysread(TAR, $mesg, 8192) <= 0 ) {
+ vec($FDread, fileno(TAR), 1) = 0;
+ close(TAR);
+ } else {
+ $tarOut .= $mesg;
+ }
+ }
+ while ( $tarOut =~ /(.*?)[\n\r]+(.*)/s ) {
+ $_ = $1;
+ $tarOut = $2;
+ $XferLOG->write(\"tarExtract: $_\n");
+ if ( /^Done: (\d+) errors, (\d+) filesExist, (\d+) sizeExist, (\d+) sizeExistComp, (\d+) filesTotal, (\d+) sizeTotal/ ) {
+ $tarErrs = $1;
+ $nFilesExist = $2;
+ $sizeExist = $3;
+ $sizeExistComp = $4;
+ $nFilesTotal = $5;
+ $sizeTotal = $6;
+ }
+ }
+ }
+ last if ( !$xfer->readOutput(\$FDread, $rout) );
+ while ( my $str = $xfer->logMsgGet ) {
+ print(LOG $bpc->timeStamp, "xfer: $str\n");
+ }
+ if ( $xfer->getStats->{fileCnt} == 1 ) {
+ #
+ # Make sure it is still the machine we expect. We do this while
+ # the transfer is running to avoid a potential race condition if
+ # the ip address was reassigned by dhcp just before we started
+ # the transfer.
+ #
+ if ( my $errMsg = CorrectHostCheck($hostIP, $host) ) {
+ $stat{hostError} = $errMsg;
+ last SCAN;
+ }
+ }
+ }
+ } else {
+ #
+ # otherwise the xfer module does everything for us
+ #
+ ($tarErrs, $nFilesExist, $sizeExist, $sizeExistComp,
+ $nFilesTotal, $sizeTotal) = $xfer->run();
+ }
+