Blame SOURCES/php-5.4.7-odbctimer.patch

4c9102
From 657494235eafe048e9fa6a19dcdb3c73a0cbe6ec Mon Sep 17 00:00:00 2001
4c9102
From: Remi Collet <fedora@famillecollet.com>
4c9102
Date: Thu, 27 Sep 2012 13:45:32 +0200
4c9102
Subject: [PATCH] Fixed bug #63171, script hangs if odbc call during timeout
4c9102
4c9102
---
4c9102
 ext/odbc/php_odbc.c |   21 ++++++++++++++-------
4c9102
 1 file changed, 14 insertions(+), 7 deletions(-)
4c9102
4c9102
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
4c9102
index 52d46b2..2169e65 100644
4c9102
--- a/ext/odbc/php_odbc.c
4c9102
+++ b/ext/odbc/php_odbc.c
4c9102
@@ -431,7 +431,8 @@ static void _free_odbc_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
4c9102
 			efree(res->values);
4c9102
 			res->values = NULL;
4c9102
 		}
4c9102
-		if (res->stmt) {
4c9102
+		/* If aborted via timer expiration, don't try to call any unixODBC function */
4c9102
+		if (res->stmt && !(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
4c9102
 #if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35)
4c9102
 			SQLTransact(res->conn_ptr->henv, res->conn_ptr->hdbc,
4c9102
 						(SQLUSMALLINT) SQL_COMMIT);
4c9102
@@ -484,9 +485,12 @@ static void _close_odbc_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
4c9102
 		}
4c9102
 	}
4c9102
 
4c9102
-   	safe_odbc_disconnect(conn->hdbc);
4c9102
-	SQLFreeConnect(conn->hdbc);
4c9102
-	SQLFreeEnv(conn->henv);
4c9102
+	/* If aborted via timer expiration, don't try to call any unixODBC function */
4c9102
+	if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
4c9102
+		safe_odbc_disconnect(conn->hdbc);
4c9102
+		SQLFreeConnect(conn->hdbc);
4c9102
+		SQLFreeEnv(conn->henv);
4c9102
+	}
4c9102
 	efree(conn);
4c9102
 	ODBCG(num_links)--;
4c9102
 }
4c9102
@@ -512,9 +516,12 @@ static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
4c9102
 		}
4c9102
 	}
4c9102
 	
4c9102
-	safe_odbc_disconnect(conn->hdbc);
4c9102
-	SQLFreeConnect(conn->hdbc);
4c9102
-	SQLFreeEnv(conn->henv);
4c9102
+	/* If aborted via timer expiration, don't try to call any unixODBC function */
4c9102
+	if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
4c9102
+		safe_odbc_disconnect(conn->hdbc);
4c9102
+		SQLFreeConnect(conn->hdbc);
4c9102
+		SQLFreeEnv(conn->henv);
4c9102
+	}
4c9102
 	free(conn);
4c9102
 
4c9102
 	ODBCG(num_links)--;
4c9102
-- 
4c9102
1.7.10
4c9102