Skip to content

Commit 1fe6c26

Browse files
Merge branch 'hotfix/3.1.4' into develop
2 parents e01e885 + 5d06863 commit 1fe6c26

File tree

9 files changed

+45
-11
lines changed

9 files changed

+45
-11
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.3
1+
3.1.4

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php": "^7.4.0 || ^8.0.0",
2323
"ext-sockets": "*",
24-
"psr/log": "^1.0"
24+
"psr/log": "^1.0 || ^2.0 || ^3.0"
2525
},
2626
"autoload": {
2727
"psr-4": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PHPWebSockets/AConnection.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ protected function _handlePacket(string $newData) : \Generator {
494494

495495
if ($res === FALSE) {
496496

497-
yield new Update\Error(Update\Error::C_WRITE_INVALID_TARGET_STREAM, $this);
497+
$errUpdate = new Update\Error(Update\Error::C_WRITE_INVALID_TARGET_STREAM, $this);
498+
$errUpdate->setAdditionalInfo(error_get_last()['message'] ?? '');
499+
yield $errUpdate;
498500

499501
$this->close();
500502

@@ -656,7 +658,9 @@ public function handleWrite() : \Generator {
656658

657659
$this->_log(LogLevel::DEBUG, ' fwrite failed');
658660

659-
yield new Update\Error(Update\Error::C_WRITE, $this);
661+
$errUpdate = new Update\Error(Update\Error::C_WRITE, $this);
662+
$errUpdate->setAdditionalInfo(error_get_last()['message'] ?? '');
663+
yield $errUpdate;
660664

661665
} elseif ($bytesWritten === $bytesToWrite) {
662666

src/PHPWebSockets/AUpdate.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ abstract class AUpdate {
3939
*/
4040
protected $_sourceConnection = NULL;
4141

42+
/**
43+
* @var string
44+
*/
45+
protected $_additionalInfo = '';
46+
4247
/**
4348
* @var array|null
4449
*/
@@ -71,6 +76,24 @@ public function getSourceConnection() : ?AConnection {
7176
return $this->_sourceConnection;
7277
}
7378

79+
/**
80+
* Sets additional information to pass on for error handling
81+
*
82+
* @param string $info
83+
*
84+
* @return void
85+
*/
86+
public function setAdditionalInfo(string $info) : void {
87+
$this->_additionalInfo = $info;
88+
}
89+
90+
/**
91+
* @return string
92+
*/
93+
public function getAdditionalInfo() : string {
94+
return $this->_additionalInfo;
95+
}
96+
7497
/**
7598
* @return array|null
7699
*/
@@ -88,6 +111,6 @@ public function getCode() : int {
88111
}
89112

90113
public function __toString() {
91-
return 'AUpdate) (C: ' . $this->getCode() . ')';
114+
return 'AUpdate) (C: ' . $this->getCode() . ')' . ($this->_additionalInfo ? ' Additional info: ' . $this->_additionalInfo : '');
92115
}
93116
}

src/PHPWebSockets/Client.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,13 @@ public function handleRead() : \Generator {
230230
$this->_log(LogLevel::DEBUG, __METHOD__);
231231

232232
$readRate = $this->getReadRate();
233-
$newData = fread($this->getStream(), min($this->_currentFrameRemainingBytes ?? $readRate, $readRate));
233+
$newData = @fread($this->getStream(), min($this->_currentFrameRemainingBytes ?? $readRate, $readRate));
234234
if ($newData === FALSE) {
235-
yield new Update\Error(Update\Error::C_READ, $this);
235+
236+
$errUpdate = new Update\Error(Update\Error::C_READ, $this);
237+
$errUpdate->setAdditionalInfo(error_get_last()['message'] ?? '');
238+
239+
yield $errUpdate;
236240

237241
return;
238242
}

src/PHPWebSockets/Server/Connection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ public function handleRead() : \Generator {
124124
$readRate = $this->getReadRate();
125125
$newData = @fread($this->getStream(), min($this->_currentFrameRemainingBytes ?? $readRate, $readRate));
126126
if ($newData === FALSE) {
127-
yield new Update\Error(Update\Error::C_READ, $this);
127+
128+
$errUpdate = new Update\Error(Update\Error::C_READ, $this);
129+
$errUpdate->setAdditionalInfo(error_get_last()['message'] ?? '');
130+
yield $errUpdate;
128131

129132
return;
130133
}

src/PHPWebSockets/Update/Error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ public function __toString() {
9191

9292
$code = $this->getCode();
9393

94-
return 'Error) ' . self::StringForCode($code) . ' (C: ' . $code . ')';
94+
return 'Error) ' . self::StringForCode($code) . ' (C: ' . $code . ')' . ($this->_additionalInfo ? ' Additional info: ' . $this->_additionalInfo : '');
9595
}
9696
}

src/PHPWebSockets/Update/Read.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ public function __toString() {
138138

139139
$code = $this->getCode();
140140

141-
return 'Read) ' . self::StringForCode($code) . ' (C: ' . $code . ')';
141+
return 'Read) ' . self::StringForCode($code) . ' (C: ' . $code . ')' . ($this->_additionalInfo ? ' Additional info: ' . $this->_additionalInfo : '');;
142142
}
143143
}

0 commit comments

Comments
 (0)