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:
parent
4fc6425fd8
commit
68c3c5fcb5
@ -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);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user