mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-23 06:31:11 +01:00
Avoid FILE_PART_0_MISSING issues when concurrently uploading report logs
This commit is contained in:
parent
ff1565c4cd
commit
8e27815b9e
@ -27,8 +27,6 @@ use danog\MadelineProto\Magic;
|
|||||||
use danog\MadelineProto\SecurityException;
|
use danog\MadelineProto\SecurityException;
|
||||||
use danog\MadelineProto\SessionPaths;
|
use danog\MadelineProto\SessionPaths;
|
||||||
use danog\MadelineProto\Settings\Ipc;
|
use danog\MadelineProto\Settings\Ipc;
|
||||||
use danog\MadelineProto\Shutdown;
|
|
||||||
use Revolt\EventLoop;
|
|
||||||
use Revolt\EventLoop\UncaughtThrowable;
|
use Revolt\EventLoop\UncaughtThrowable;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ final class Logger
|
|||||||
$this->prefix = $prefix === '' ? '' : ', '.$prefix;
|
$this->prefix = $prefix === '' ? '' : ', '.$prefix;
|
||||||
|
|
||||||
$this->mode = $settings->getType();
|
$this->mode = $settings->getType();
|
||||||
$this->level = $settings->getLevel();
|
$this->level = self::LEVEL_ULTRA_VERBOSE;
|
||||||
|
|
||||||
$optional = $settings->getExtra();
|
$optional = $settings->getExtra();
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ use Amp\DeferredFuture;
|
|||||||
use Amp\Dns\DnsResolver;
|
use Amp\Dns\DnsResolver;
|
||||||
use Amp\Future;
|
use Amp\Future;
|
||||||
use Amp\Http\Client\HttpClient;
|
use Amp\Http\Client\HttpClient;
|
||||||
|
use Amp\Sync\LocalMutex;
|
||||||
use danog\MadelineProto\Db\DbArray;
|
use danog\MadelineProto\Db\DbArray;
|
||||||
use danog\MadelineProto\Db\DbPropertiesFactory;
|
use danog\MadelineProto\Db\DbPropertiesFactory;
|
||||||
use danog\MadelineProto\Db\DbPropertiesTrait;
|
use danog\MadelineProto\Db\DbPropertiesTrait;
|
||||||
@ -1752,6 +1753,7 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
/** @var array<int> $userOrId */
|
/** @var array<int> $userOrId */
|
||||||
$this->reportDest = $userOrId;
|
$this->reportDest = $userOrId;
|
||||||
}
|
}
|
||||||
|
private ?LocalMutex $reportMutex = null;
|
||||||
/**
|
/**
|
||||||
* Report an error to the previously set peer.
|
* Report an error to the previously set peer.
|
||||||
*
|
*
|
||||||
@ -1763,6 +1765,9 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
if (!$this->reportDest) {
|
if (!$this->reportDest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$this->reportMutex ??= new LocalMutex;
|
||||||
|
$lock = $this->reportMutex->acquire();
|
||||||
|
try {
|
||||||
$file = null;
|
$file = null;
|
||||||
if ($this->settings->getLogger()->getType() === Logger::FILE_LOGGER
|
if ($this->settings->getLogger()->getType() === Logger::FILE_LOGGER
|
||||||
&& $path = $this->settings->getLogger()->getExtra()) {
|
&& $path = $this->settings->getLogger()->getExtra()) {
|
||||||
@ -1801,6 +1806,9 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
$this->logger->truncate();
|
$this->logger->truncate();
|
||||||
$this->logger->logger('Reported!');
|
$this->logger->logger('Reported!');
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
$lock->release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get full list of MTProto and API methods.
|
* Get full list of MTProto and API methods.
|
||||||
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace danog\MadelineProto\MTProtoTools;
|
namespace danog\MadelineProto\MTProtoTools;
|
||||||
|
|
||||||
use Amp\ByteStream\Payload;
|
|
||||||
use Amp\ByteStream\Pipe;
|
use Amp\ByteStream\Pipe;
|
||||||
use Amp\ByteStream\ReadableResourceStream;
|
use Amp\ByteStream\ReadableResourceStream;
|
||||||
use Amp\ByteStream\ReadableStream;
|
use Amp\ByteStream\ReadableStream;
|
||||||
|
@ -207,7 +207,7 @@ final class ReferenceDatabase implements TLCallback
|
|||||||
throw new Exception("Unknown origin type provided: {$type}");
|
throw new Exception("Unknown origin type provided: {$type}");
|
||||||
}
|
}
|
||||||
$originContext = self::CONSTRUCTOR_CONTEXT[$type];
|
$originContext = self::CONSTRUCTOR_CONTEXT[$type];
|
||||||
//$this->API->logger->logger("Adding origin context {$originContext} for {$type}!", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
$this->API->logger->logger("Adding origin context {$originContext} for {$type}!", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
$this->cacheContexts[] = $originContext;
|
$this->cacheContexts[] = $originContext;
|
||||||
}
|
}
|
||||||
public function addOrigin(array $data = []): void
|
public function addOrigin(array $data = []): void
|
||||||
@ -218,7 +218,7 @@ final class ReferenceDatabase implements TLCallback
|
|||||||
}
|
}
|
||||||
$originType = \array_pop($this->cacheContexts);
|
$originType = \array_pop($this->cacheContexts);
|
||||||
if (!isset($this->cache[$key])) {
|
if (!isset($this->cache[$key])) {
|
||||||
//$this->API->logger->logger("Removing origin context {$originType} for {$data['_']}, nothing in the reference cache!", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
$this->API->logger->logger("Removing origin context {$originType} for {$data['_']}, nothing in the reference cache!", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$cache = $this->cache[$key];
|
$cache = $this->cache[$key];
|
||||||
|
@ -169,7 +169,7 @@ trait UpdateHandler
|
|||||||
'offset' => $offset,
|
'offset' => $offset,
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'timeout' => $timeout
|
'timeout' => $timeout
|
||||||
] = array_merge(['offset' => 0, 'limit' => null, 'timeout' => INF], $params);
|
] = \array_merge(['offset' => 0, 'limit' => null, 'timeout' => INF], $params);
|
||||||
|
|
||||||
if (!$this->updates) {
|
if (!$this->updates) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user