Blame SOURCES/php-5.4.7-odbctimer.patch

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