Defer resolution of update deferred

This commit is contained in:
Daniil Gentili 2019-05-13 01:35:53 +02:00
parent 34e957e811
commit 48dad117c2
3 changed files with 7 additions and 2 deletions

View File

@ -99,7 +99,9 @@ class ReadLoop extends SignalLoop
$connection->http_res_count++;
try {
$API->logger->logger("Handling messages from DC ".$datacenter, \danog\MadelineProto\Logger::ULTRA_VERBOSE);
$API->handle_messages($datacenter);
$API->logger->logger("Handled messages from DC ".$datacenter, \danog\MadelineProto\Logger::ULTRA_VERBOSE);
} finally {
$this->exitedLoop();
}

View File

@ -543,6 +543,8 @@ trait ResponseHandler
$botAPI = isset($request['botAPI']) && $request['botAPI'];
unset($request);
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
$r = isset($response['_']) ? $response['_'] : json_encode($response);
$this->logger->logger("Defer sending $r to deferred");
$this->callFork((
function () use ($request_id, $response, $datacenter, $botAPI) {
$r = isset($response['_']) ? $response['_'] : json_encode($response);
@ -653,7 +655,7 @@ trait ResponseHandler
$d = $this->update_deferred;
$this->update_deferred = null;
$d->resolve();
Loop::defer([$d, 'resolve']);
}
}
}

View File

@ -22,6 +22,7 @@ namespace danog\MadelineProto\MTProtoTools;
use Amp\Artax\Request;
use Amp\Deferred;
use Amp\Delayed;
use Amp\Loop;
use function Amp\Promise\any;
/**
@ -292,7 +293,7 @@ trait UpdateHandler
$d = $this->update_deferred;
$this->update_deferred = null;
$d->resolve();
Loop::defer([$d, 'resolve']);
}
return true;