diff options
author | Josh Kelley <josh.kelley@nih.gov> | 2020-01-28 20:05:33 +0100 |
---|---|---|
committer | Josh Kelley <joshkel@gmail.com> | 2020-01-28 20:11:34 +0100 |
commit | 1be5b1f14920ee599c5c7ee716c973b1b87da0b6 (patch) | |
tree | f15d0f7c00cf0dfa2edbde53e35e01cfd9a87705 /system | |
parent | ddfe81730f43b20092383165911c5b1c92d4e5f3 (diff) |
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 <joshkel@gmail.com>
Diffstat (limited to 'system')
-rw-r--r-- | system/database/drivers/pdo/pdo_driver.php | 13 |
1 files changed, 13 insertions, 0 deletions
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; + } + } |