Bugfixes and performance improvements
This commit is contained in:
parent
c04a05f0ac
commit
4121a3f017
@ -119,8 +119,8 @@ If not, see <http://www.gnu.org/licenses/>.
|
||||
{
|
||||
$packet = '';
|
||||
$try = 0;
|
||||
while (strlen($packet) < $length) {
|
||||
$read = stream_get_contents($this->sock, $length - strlen($packet));
|
||||
while (($current_length = strlen($packet)) < $length) {
|
||||
$read = stream_get_contents($this->sock, $length - $current_length);
|
||||
if ($read === false || (strlen($read) === 0 && $try > 10)) {
|
||||
throw new \danog\MadelineProto\NothingInTheSocketException('Nothing in the socket!');
|
||||
}
|
||||
@ -139,10 +139,15 @@ If not, see <http://www.gnu.org/licenses/>.
|
||||
$buffer = substr($buffer, 0, $length);
|
||||
}
|
||||
|
||||
$wrote = 0;
|
||||
if (($wrote += fwrite($this->sock, $buffer, $length)) !== $length) {
|
||||
while (($wrote += fwrite($this->sock, substr($buffer, $wrote), $length - $wrote)) !== $length) {
|
||||
$try = 0;
|
||||
$wrote = fwrite($this->sock, $buffer, $length);
|
||||
while ($wrote < $length) {
|
||||
$wrote_now = fwrite($this->sock, substr($buffer, $wrote), $length - $wrote);
|
||||
if ($wrote_now === false || ($wrote_now === 0 && $try > 10)) {
|
||||
throw new \danog\MadelineProto\NothingInTheSocketException('Nothing could be written in the socket!');
|
||||
}
|
||||
$wrote += $wrote_now;
|
||||
$try++;
|
||||
}
|
||||
|
||||
return $wrote;
|
||||
@ -306,10 +311,16 @@ if (!extension_loaded('pthreads')) {
|
||||
$buffer = substr($buffer, 0, $length);
|
||||
}
|
||||
|
||||
$wrote = 0;
|
||||
if (($wrote += socket_write($this->sock, $buffer, $length)) !== $length) {
|
||||
while (($wrote += socket_write($this->sock, substr($buffer, $wrote), $length - $wrote)) !== $length) {
|
||||
|
||||
$try = 0;
|
||||
$wrote = socket_write($this->sock, $buffer, $length);
|
||||
while ($wrote < $length) {
|
||||
$wrote_now = socket_write($this->sock, substr($buffer, $wrote), $length - $wrote);
|
||||
if ($wrote_now === false || ($wrote_now === 0 && $try > 10)) {
|
||||
throw new \danog\MadelineProto\NothingInTheSocketException('Nothing could be written in the socket!');
|
||||
}
|
||||
$wrote += $wrote_now;
|
||||
$try++;
|
||||
}
|
||||
|
||||
return $wrote;
|
||||
|
@ -27,12 +27,11 @@ abstract class CombinedEventHandler
|
||||
|
||||
final public function __sleep()
|
||||
{
|
||||
$keys = get_object_vars($this);
|
||||
$keys = method_exists($this, '__magic_sleep') ? $this->__magic_sleep() : get_object_vars($this);
|
||||
unset($keys['CombinedAPI']);
|
||||
foreach ($this->CombinedAPI->instance_paths as $path) {
|
||||
unset($keys[$path]);
|
||||
}
|
||||
|
||||
return array_keys($keys);
|
||||
}
|
||||
|
||||
|
@ -344,6 +344,9 @@ trait ResponseHandler
|
||||
}
|
||||
switch ($server_answer['error_code']) {
|
||||
case 500:
|
||||
if ($server_answer['error_message'] === 'MSG_WAIT_FAILED') {
|
||||
throw new \danog\MadelineProto\RPCErrorException($server_answer['error_message'], $server_answer['error_code']);
|
||||
}
|
||||
throw new \danog\MadelineProto\Exception('Re-executing query after server error...');
|
||||
case 303:
|
||||
$this->datacenter->curdc = $aargs['datacenter'] = (int) preg_replace('/[^0-9]+/', '', $server_answer['error_message']);
|
||||
|
@ -605,6 +605,10 @@ trait UpdateHandler
|
||||
if (isset($this->temp_requested_secret_chats[$update['chat']['id']])) {
|
||||
unset($this->temp_requested_secret_chats[$update['chat']['id']]);
|
||||
}
|
||||
if (isset($this->temp_rekeyed_secret_chats[$update['chat']['id']])) {
|
||||
unset($this->temp_rekeyed_secret_chats[$update['chat']['id']]);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'encryptedChat':
|
||||
$this->logger->logger('Completing creation of secret chat '.$update['chat']['id'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user