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