1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-30 04:29:12 +01:00

Check polling status even without active query

This commit is contained in:
Aaron Piotrowski 2017-11-05 11:28:32 -06:00
parent 4fc6425fd8
commit 68c3c5fcb5
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -64,19 +64,23 @@ class PqHandle implements Handle {
$listeners = &$this->listeners;
$this->poll = Loop::onReadable($this->handle->socket, static function ($watcher) use (&$deferred, &$listeners, $handle) {
$status = $handle->poll();
if ($handle->poll() === pq\Connection::POLLING_FAILED) {
$deferred->fail(new FailureException($handle->errorMessage));
Loop::disable($watcher);
return;
}
if ($deferred === null) {
return; // No active query, only notification listeners.
}
if ($status === pq\Connection::POLLING_FAILED) {
$deferred->fail(new FailureException($handle->errorMessage));
} elseif (!$handle->busy) {
$deferred->resolve($handle->getResult());
if ($handle->busy) {
return; // Not finished receiving data, poll again.
}
if (!$deferred && !$handle->busy && empty($listeners)) {
$deferred->resolve($handle->getResult());
if (!$deferred && empty($listeners)) {
Loop::disable($watcher);
}
});