Skip to content

Commit 34f7482

Browse files
committed
Add check for bad connection
1 parent 1579d9f commit 34f7482

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/PgSqlHandle.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ public function __construct($handle, $socket)
7171
$this->poll = Loop::onReadable($socket, static function ($watcher) use (&$deferred, &$lastUsedAt, &$listeners, &$handle): void {
7272
$lastUsedAt = \time();
7373

74+
if (\pg_connection_status($handle) === \PGSQL_CONNECTION_BAD) {
75+
$handle = null;
76+
77+
if ($deferred) {
78+
$deferred->fail(new ConnectionException("The connection closed during the operation"));
79+
}
80+
}
81+
7482
if (!\pg_consume_input($handle)) {
7583
$handle = null; // Marks connection as dead.
7684
Loop::disable($watcher);

0 commit comments

Comments
 (0)