1 |
From 657494235eafe048e9fa6a19dcdb3c73a0cbe6ec Mon Sep 17 00:00:00 2001 |
2 |
From: Remi Collet <fedora@famillecollet.com> |
3 |
Date: Thu, 27 Sep 2012 13:45:32 +0200 |
4 |
Subject: [PATCH] Fixed bug #63171, script hangs if odbc call during timeout |
5 |
|
6 |
--- |
7 |
ext/odbc/php_odbc.c | 21 ++++++++++++++------- |
8 |
1 file changed, 14 insertions(+), 7 deletions(-) |
9 |
|
10 |
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c |
11 |
index 52d46b2..2169e65 100644 |
12 |
--- a/ext/odbc/php_odbc.c |
13 |
+++ b/ext/odbc/php_odbc.c |
14 |
@@ -431,7 +431,8 @@ static void _free_odbc_result(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
15 |
efree(res->values); |
16 |
res->values = NULL; |
17 |
} |
18 |
- if (res->stmt) { |
19 |
+ /* If aborted via timer expiration, don't try to call any unixODBC function */ |
20 |
+ if (res->stmt && !(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) { |
21 |
#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35) |
22 |
SQLTransact(res->conn_ptr->henv, res->conn_ptr->hdbc, |
23 |
(SQLUSMALLINT) SQL_COMMIT); |
24 |
@@ -484,9 +485,12 @@ static void _close_odbc_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
25 |
} |
26 |
} |
27 |
|
28 |
- safe_odbc_disconnect(conn->hdbc); |
29 |
- SQLFreeConnect(conn->hdbc); |
30 |
- SQLFreeEnv(conn->henv); |
31 |
+ /* If aborted via timer expiration, don't try to call any unixODBC function */ |
32 |
+ if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) { |
33 |
+ safe_odbc_disconnect(conn->hdbc); |
34 |
+ SQLFreeConnect(conn->hdbc); |
35 |
+ SQLFreeEnv(conn->henv); |
36 |
+ } |
37 |
efree(conn); |
38 |
ODBCG(num_links)--; |
39 |
} |
40 |
@@ -512,9 +516,12 @@ static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
41 |
} |
42 |
} |
43 |
|
44 |
- safe_odbc_disconnect(conn->hdbc); |
45 |
- SQLFreeConnect(conn->hdbc); |
46 |
- SQLFreeEnv(conn->henv); |
47 |
+ /* If aborted via timer expiration, don't try to call any unixODBC function */ |
48 |
+ if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) { |
49 |
+ safe_odbc_disconnect(conn->hdbc); |
50 |
+ SQLFreeConnect(conn->hdbc); |
51 |
+ SQLFreeEnv(conn->henv); |
52 |
+ } |
53 |
free(conn); |
54 |
|
55 |
ODBCG(num_links)--; |
56 |
-- |
57 |
1.7.10 |
58 |
|