mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
remove connection from pool if explicitly closed
This commit is contained in:
parent
ea2a107069
commit
a62c90d092
2 changed files with 9 additions and 3 deletions
|
@ -38,6 +38,7 @@ module DB
|
||||||
protected def do_close
|
protected def do_close
|
||||||
@statements_cache.each_value &.close
|
@statements_cache.each_value &.close
|
||||||
@statements_cache.clear
|
@statements_cache.clear
|
||||||
|
@database.pool.delete self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -88,8 +88,7 @@ module DB
|
||||||
rescue e : ConnectionLost
|
rescue e : ConnectionLost
|
||||||
# if the connection is lost close it to release resources
|
# if the connection is lost close it to release resources
|
||||||
# and remove it from the known pool.
|
# and remove it from the known pool.
|
||||||
@total.delete(e.connection)
|
delete(e.connection)
|
||||||
@available.delete(e.connection)
|
|
||||||
e.connection.close
|
e.connection.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -103,11 +102,17 @@ module DB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# :nodon:
|
# :nodoc:
|
||||||
def is_available?(resource : T)
|
def is_available?(resource : T)
|
||||||
@available.includes?(resource)
|
@available.includes?(resource)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
def delete(resource : T)
|
||||||
|
@total.delete(resource)
|
||||||
|
@available.delete(resource)
|
||||||
|
end
|
||||||
|
|
||||||
private def build_resource : T
|
private def build_resource : T
|
||||||
resource = @factory.call
|
resource = @factory.call
|
||||||
@total << resource
|
@total << resource
|
||||||
|
|
Loading…
Reference in a new issue