Fix BINKP transfers when tcp buffer has more chars than we need at that point in time

This commit is contained in:
Deon George 2023-07-07 23:13:43 +10:00
parent 30c11956dd
commit ad4ea699a5

View File

@ -359,9 +359,9 @@ final class Binkp extends BaseProtocol
if ($blksz !== 0) {
try {
Log::debug(sprintf('%s:- Reading [%d] chars, buffer currently has [%d] chars',self::LOGKEY,$blksz,strlen($this->rx_buf)));
$rx_buf = $this->client->read(0,$blksz);
Log::debug(sprintf('%s:- Read buffer now has [%d] chars',self::LOGKEY,strlen($rx_buf)));
Log::debug(sprintf('%s:- We need [%d] more chars, buffer currently has [%d] chars',self::LOGKEY,$blksz,strlen($this->rx_buf)));
$rx_buf = $this->client->read(0,$blksz-strlen($this->rx_buf));
Log::debug(sprintf('%s:- Got [%d] more chars for the read buffer',self::LOGKEY,strlen($rx_buf)));
} catch (SocketException $e) {
if ($e->getCode() === 11) {
@ -389,8 +389,7 @@ final class Binkp extends BaseProtocol
$this->rx_buf .= ($this->capGet(self::F_CRYPT,self::O_YES)) ? $this->crypt_in->decrypt($rx_buf) : $rx_buf;
}
if ($this->DEBUG)
Log::debug(sprintf('%s: - binkp_recv rx_buf [%d] blksz [%d].',self::LOGKEY,strlen($this->rx_buf),$blksz));
Log::debug(sprintf('%s:- Read buffer has [%d] chars to process.',self::LOGKEY,strlen($this->rx_buf)));
/* Received complete block */
if (strlen($this->rx_buf) === $blksz) {