mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-26 20:04:45 +01:00
Add mutex
This commit is contained in:
parent
561fec0a12
commit
40d16c372a
@ -52,6 +52,7 @@ class Client
|
|||||||
|
|
||||||
public function addSession(string $session, array $settings = []): API
|
public function addSession(string $session, array $settings = []): API
|
||||||
{
|
{
|
||||||
|
$this->mutex ??= new LocalKeyedMutex;
|
||||||
$lock = $this->mutex->acquire($session);
|
$lock = $this->mutex->acquire($session);
|
||||||
if (isset($this->instances[$session])) {
|
if (isset($this->instances[$session])) {
|
||||||
throw new InvalidArgumentException('Session already exists');
|
throw new InvalidArgumentException('Session already exists');
|
||||||
|
Loading…
Reference in New Issue
Block a user