From 1be5b1f14920ee599c5c7ee716c973b1b87da0b6 Mon Sep 17 00:00:00 2001 From: Josh Kelley Date: Tue, 28 Jan 2020 14:05:33 -0500 Subject: Fix database connection leak when closing PDO connection We discovered a resource leak (database connection leak) in our application's test suite. We investigated and discovered that, although the test suite was calling `CI_DB_driver::close()` after each test, the `result_id` member variable still maintained an internal reference to the database connection, which kept the connection from being closed. This is using pdo_sqlsrv; I have not tested other PDO drivers. Signed-off-by: Josh Kelley --- system/database/drivers/pdo/pdo_driver.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 614d35096..b23e8cbda 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -326,4 +326,17 @@ class CI_DB_pdo_driver extends CI_DB { return 'TRUNCATE TABLE '.$table; } + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + $this->result_id = FALSE; + $this->conn_id = FALSE; + } + } -- cgit v1.2.3-24-g4f1b