SFTP: a few tweaks to the queue'd get() changes raxbg did

This commit is contained in:
terrafrost 2016-03-14 09:57:54 -05:00
parent 815f227897
commit 6d5ec59f10

View File

@ -2068,11 +2068,11 @@ class SFTP extends SSH2
$i = 0; $i = 0;
while ($i < NET_SFTP_QUEUE_SIZE && ($length < 0 || $read < $length)) { while ($i < NET_SFTP_QUEUE_SIZE && ($length < 0 || $read < $length)) {
$subtemp = $start + $read; $tempoffset = $start + $read;
$packet_size = $length > 0 ? min($this->max_sftp_packet, $length - $read) : $this->max_sftp_packet; $packet_size = $length > 0 ? min($this->max_sftp_packet, $length - $read) : $this->max_sftp_packet;
$packet = pack('Na*N3', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, $packet_size); $packet = pack('Na*N3', strlen($handle), $handle, $tempoffset / 4294967296, $tempoffset, $packet_size);
if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) { if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) {
if ($fclose_check) { if ($fclose_check) {
fclose($fp); fclose($fp);
@ -2084,12 +2084,15 @@ class SFTP extends SSH2
$i++; $i++;
} }
if ($i > 0) { if (!$i) {
$break_loop = false; break;
}
$clear_responses = false;
while ($i > 0) { while ($i > 0) {
$i--; $i--;
if ($break_loop) { if ($clear_responses) {
$this->_get_sftp_packet(); $this->_get_sftp_packet();
continue; continue;
} else { } else {
@ -2110,7 +2113,7 @@ class SFTP extends SSH2
case NET_SFTP_STATUS: case NET_SFTP_STATUS:
// could, in theory, return false if !strlen($content) but we'll hold off for the time being // could, in theory, return false if !strlen($content) but we'll hold off for the time being
$this->_logError($response); $this->_logError($response);
$break_loop = true; // don't break out of the loop yet, so we can read the remaining responses $clear_responses = true; // don't break out of the loop yet, so we can read the remaining responses
break; break;
default: default:
if ($fclose_check) { if ($fclose_check) {
@ -2121,10 +2124,7 @@ class SFTP extends SSH2
$response = null; $response = null;
} }
if ($break_loop) { if ($clear_responses) {
break;
}
} else {
break; break;
} }
} }