1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 21:51:34 +01:00

Fix memory leak, bump to layer 174

This commit is contained in:
Daniil Gentili 2024-02-20 10:45:38 +01:00
parent 37a66c3eb2
commit 22b95db565
11 changed files with 71 additions and 2284 deletions

View File

@ -955,6 +955,8 @@ Want to add your own open-source project to this list? [Click here!](https://doc
* <a href="https://docs.madelineproto.xyz/API_docs/methods/bots.invokeWebViewCustomMethod.html" name="bots.invokeWebViewCustomMethod">bots.invokeWebViewCustomMethod</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.clickSponsoredMessage.html" name="channels.clickSponsoredMessage">channels.clickSponsoredMessage</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getChannelRecommendations.html" name="channels.getChannelRecommendations">channels.getChannelRecommendations</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.setBoostsToUnblockRestrictions.html" name="channels.setBoostsToUnblockRestrictions">channels.setBoostsToUnblockRestrictions</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.setEmojiStickers.html" name="channels.setEmojiStickers">channels.setEmojiStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.toggleViewForumAsMessages.html" name="channels.toggleViewForumAsMessages">channels.toggleViewForumAsMessages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.updateColor.html" name="channels.updateColor">channels.updateColor</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.updateEmojiStatus.html" name="channels.updateEmojiStatus">channels.updateEmojiStatus</a>

2
docs

@ -1 +1 @@
Subproject commit 8cb943830d37ffbca62dae654e9358c87a877a5b
Subproject commit 5b7e3ec1f68ed3c3c1843ba35eccbbc0354fa9e0

View File

@ -235,6 +235,9 @@ final class ReadLoop extends Loop
} catch (\Throwable $e) {
Logger::log('Error during deserializing message (base64): ' . base64_encode($message_data), Logger::ERROR);
throw $e;
} finally {
$this->API->minDatabase->reset();
$this->API->referenceDatabase->reset();
}
$message = new MTProtoIncomingMessage($deserialized, $message_id, $unencrypted);

View File

@ -184,6 +184,17 @@ final class ReferenceDatabase implements TLCallback
return [];
}
public function reset(): void
{
if ($this->cache) {
$this->API->logger('Found '.\count($this->cache).' pending contexts', Logger::ERROR);
$this->cache = [];
}
if ($this->cacheContexts) {
$this->API->logger('Found '.\count($this->cacheContexts).' pending contexts', Logger::ERROR);
$this->cacheContexts = [];
}
}
public function addReference(array $location): bool
{
if (!$this->cacheContexts) {

File diff suppressed because one or more lines are too long

View File

@ -249,7 +249,7 @@ interface Help
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return array{_: 'help.peerColorsNotModified'}|array{_: 'help.peerColors', hash: int, colors: list<array{_: 'help.peerColorOption', hidden: bool, color_id: int, colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, dark_colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, channel_min_level?: int}>} @see https://docs.madelineproto.xyz/API_docs/types/help.PeerColors.html
* @return array{_: 'help.peerColorsNotModified'}|array{_: 'help.peerColors', hash: int, colors: list<array{_: 'help.peerColorOption', hidden: bool, color_id: int, colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, dark_colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, channel_min_level?: int, group_min_level?: int}>} @see https://docs.madelineproto.xyz/API_docs/types/help.PeerColors.html
*/
public function getPeerColors(int|null $hash = 0, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
@ -259,7 +259,7 @@ interface Help
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return array{_: 'help.peerColorsNotModified'}|array{_: 'help.peerColors', hash: int, colors: list<array{_: 'help.peerColorOption', hidden: bool, color_id: int, colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, dark_colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, channel_min_level?: int}>} @see https://docs.madelineproto.xyz/API_docs/types/help.PeerColors.html
* @return array{_: 'help.peerColorsNotModified'}|array{_: 'help.peerColors', hash: int, colors: list<array{_: 'help.peerColorOption', hidden: bool, color_id: int, colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, dark_colors?: array{_: 'help.peerColorSet', colors: list<int>}|array{_: 'help.peerColorProfileSet', palette_colors: list<int>, bg_colors: list<int>, story_colors: list<int>}, channel_min_level?: int, group_min_level?: int}>} @see https://docs.madelineproto.xyz/API_docs/types/help.PeerColors.html
*/
public function getPeerProfileColors(int|null $hash = 0, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,11 +27,11 @@ final class TLSchema extends SettingsAbstract
/**
* TL layer version.
*/
protected int $layer = 173;
protected int $layer = 174;
/**
* API schema path.
*/
protected string $APISchema = __DIR__ . '/../TL_telegram_v173.tl';
protected string $APISchema = __DIR__ . '/../TL_telegram_v174.tl';
/**
* MTProto schema path.
*/

File diff suppressed because it is too large Load Diff