Merge pull request #549 from limingxinleo/1.0-amqp

Optimized swooleIO.
This commit is contained in:
李铭昕 2019-09-10 11:08:18 +08:00 committed by GitHub
commit a9a0279d8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -9,6 +9,10 @@
[#545](https://github.com/hyperf-cloud/hyperf/pull/545) Deleted useless static methods `restoring` and `restored` of trait SoftDeletes.
## Optimized
[#549](https://github.com/hyperf-cloud/hyperf/pull/549) Optimized `read` and `write` of `Hyperf\Amqp\Connection\SwooleIO`.
# v1.0.14 - 2019-09-05
## Added

View File

@ -158,7 +158,6 @@ class SwooleIO extends AbstractIO
public function read($len)
{
$this->check_heartbeat();
$count = 0;
do {
if ($len <= strlen($this->buffer)) {
$data = substr($this->buffer, 0, $len);
@ -178,10 +177,7 @@ class SwooleIO extends AbstractIO
}
if ($read_buffer === '') {
if (5 < $count++) {
throw new AMQPRuntimeException('The receiving data is empty, errno=' . $this->sock->errCode);
}
continue;
throw new AMQPRuntimeException('Connection is closed.');
}
$this->buffer .= $read_buffer;
@ -192,8 +188,8 @@ class SwooleIO extends AbstractIO
/**
* @param string $data
* @throws AMQPRuntimeException
* @throws \PhpAmqpLib\Exception\AMQPTimeoutException
* @throws AMQPRuntimeException
* @return mixed|void
*/
public function write($data)
@ -204,10 +200,6 @@ class SwooleIO extends AbstractIO
throw new AMQPRuntimeException('Error sending data');
}
if ($buffer === 0 && ! $this->sock->connected) {
throw new AMQPRuntimeException('Broken pipe or closed connection');
}
$this->lastWrite = microtime(true);
}