php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch 0001-pdo_mysql-end-restart-persistent-sessions.txt for PDO MySQL Bug #77289

Patch version 2019-01-08 15:21 UTC

Return to Bug #77289 | Download this patch
Patch Revisions:

Developer: lauri.kentta@gmail.com

From 4a41db731a1909cfa2ff6f49a1161404aa748a2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lauri=20Kentt=C3=A4?= <lauri.kentta@gmail.com>
Date: Tue, 8 Jan 2019 17:19:19 +0200
Subject: [PATCH] pdo_mysql: end/restart persistent sessions

---
 ext/pdo_mysql/mysql_driver.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index 3ff03e54b3..eb6934f769 100644
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -509,6 +509,21 @@ static int pdo_mysql_check_liveness(pdo_dbh_t *dbh)
 }
 /* }}} */
 
+/* {{{ pdo_mysql_request_shutdown */
+static void pdo_mysql_request_shutdown(pdo_dbh_t *dbh)
+{
+	pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
+
+	PDO_DBG_ENTER("pdo_mysql_request_shutdown");
+	PDO_DBG_INF_FMT("dbh=%p", dbh);
+#ifdef PDO_USE_MYSQLND
+	if (H->server) {
+		mysqlnd_end_psession(H->server);
+	}
+#endif
+}
+/* }}} */
+
 /* {{{ mysql_methods */
 static const struct pdo_dbh_methods mysql_methods = {
 	mysql_handle_closer,
@@ -524,7 +539,7 @@ static const struct pdo_dbh_methods mysql_methods = {
 	pdo_mysql_get_attribute,
 	pdo_mysql_check_liveness,
 	NULL,
-	NULL,
+	pdo_mysql_request_shutdown,
 	NULL
 };
 /* }}} */
@@ -589,6 +604,11 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
 		pdo_mysql_error(dbh);
 		goto cleanup;
 	}
+#if defined(PDO_USE_MYSQLND)
+	if (dbh->is_persistent) {
+		mysqlnd_restart_psession(H->server);
+	}
+#endif
 
 	dbh->driver_data = H;
 
-- 
2.20.1

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 23:01:32 2024 UTC