Skip to content

Commit 74005a9

Browse files
authored
fix #527
fix #527
1 parent 3c2a653 commit 74005a9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Connection/TcpConnection.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,15 +601,14 @@ public function baseRead($socket, $check_eof = true)
601601
$this->_recvBuffer .= $buffer;
602602
}
603603

604-
$recv_len = \strlen($this->_recvBuffer);
605604
// If the application layer protocol has been set up.
606605
if ($this->protocol !== null) {
607606
$parser = $this->protocol;
608607
while ($this->_recvBuffer !== '' && !$this->_isPaused) {
609608
// The current packet length is known.
610609
if ($this->_currentPackageLength) {
611610
// Data is not enough for a package.
612-
if ($this->_currentPackageLength > $recv_len) {
611+
if ($this->_currentPackageLength > \strlen($this->_recvBuffer)) {
613612
break;
614613
}
615614
} else {
@@ -624,7 +623,7 @@ public function baseRead($socket, $check_eof = true)
624623
break;
625624
} elseif ($this->_currentPackageLength > 0 && $this->_currentPackageLength <= $this->maxPackageSize) {
626625
// Data is not enough for a package.
627-
if ($this->_currentPackageLength > $recv_len) {
626+
if ($this->_currentPackageLength > \strlen($this->_recvBuffer)) {
628627
break;
629628
}
630629
} // Wrong package.
@@ -638,15 +637,14 @@ public function baseRead($socket, $check_eof = true)
638637
// The data is enough for a packet.
639638
++self::$statistics['total_request'];
640639
// The current packet length is equal to the length of the buffer.
641-
if ($recv_len === $this->_currentPackageLength) {
640+
if (\strlen($this->_recvBuffer) === $this->_currentPackageLength) {
642641
$one_request_buffer = $this->_recvBuffer;
643642
$this->_recvBuffer = '';
644643
} else {
645644
// Get a full package from the buffer.
646645
$one_request_buffer = \substr($this->_recvBuffer, 0, $this->_currentPackageLength);
647646
// Remove the current package from the receive buffer.
648647
$this->_recvBuffer = \substr($this->_recvBuffer, $this->_currentPackageLength);
649-
$recv_len = \strlen($this->_recvBuffer);
650648
}
651649
// Reset the current packet length to 0.
652650
$this->_currentPackageLength = 0;

0 commit comments

Comments
 (0)