summaryrefslogtreecommitdiff
path: root/ext/odbc/php_odbc.c
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2016-06-12 18:56:55 +0100
committerJakub Zelenka <bukka@php.net>2016-06-12 18:56:55 +0100
commitb44cf1a8540d321583a0d83ebca688ebab10d3b0 (patch)
treeb7fbafb4113ea150381a9bba7f98f45027e35b0b /ext/odbc/php_odbc.c
parent6ac8bc4ecb1fdf112eefdd16d2c4f971e7ac232a (diff)
parenta2f4c32eb14221de79009aadaa3da9c3349e3526 (diff)
downloadphp-git-b44cf1a8540d321583a0d83ebca688ebab10d3b0.tar.gz
Merge branch 'PHP-7.0' into openssl_error_store
Diffstat (limited to 'ext/odbc/php_odbc.c')
-rw-r--r--ext/odbc/php_odbc.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index d835dfb9a0..f432dcd551 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -412,7 +412,7 @@ zend_module_entry odbc_module_entry = {
#ifdef COMPILE_DL_ODBC
#ifdef ZTS
-ZEND_TSRMLS_CACHE_DEFINE();
+ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(odbc)
#endif
@@ -434,7 +434,8 @@ static void _free_odbc_result(zend_resource *rsrc)
efree(res->values);
res->values = NULL;
}
- if (res->stmt) {
+ /* If aborted via timer expiration, don't try to call any unixODBC function */
+ if (res->stmt && !(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35)
SQLTransact(res->conn_ptr->henv, res->conn_ptr->hdbc,
(SQLUSMALLINT) SQL_COMMIT);
@@ -487,9 +488,12 @@ static void _close_odbc_conn(zend_resource *rsrc)
}
} ZEND_HASH_FOREACH_END();
- safe_odbc_disconnect(conn->hdbc);
- SQLFreeConnect(conn->hdbc);
- SQLFreeEnv(conn->henv);
+ /* If aborted via timer expiration, don't try to call any unixODBC function */
+ if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
+ safe_odbc_disconnect(conn->hdbc);
+ SQLFreeConnect(conn->hdbc);
+ SQLFreeEnv(conn->henv);
+ }
efree(conn);
ODBCG(num_links)--;
}
@@ -512,9 +516,12 @@ static void _close_odbc_pconn(zend_resource *rsrc)
}
} ZEND_HASH_FOREACH_END();
- safe_odbc_disconnect(conn->hdbc);
- SQLFreeConnect(conn->hdbc);
- SQLFreeEnv(conn->henv);
+ /* If aborted via timer expiration, don't try to call any unixODBC function */
+ if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
+ safe_odbc_disconnect(conn->hdbc);
+ SQLFreeConnect(conn->hdbc);
+ SQLFreeEnv(conn->henv);
+ }
free(conn);
ODBCG(num_links)--;
@@ -1535,7 +1542,7 @@ PHP_FUNCTION(odbc_cursor)
result->stmt, state, &error, errormsg,
sizeof(errormsg)-1, &errormsgsize);
if (!strncmp(state,"S1015",5)) {
- snprintf(cursorname, max_len+1, "php_curs_%d", (int)result->stmt);
+ snprintf(cursorname, max_len+1, "php_curs_" ZEND_ULONG_FMT, (zend_ulong)result->stmt);
if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS) {
odbc_sql_error(result->conn_ptr, result->stmt, "SQLSetCursorName");
RETVAL_FALSE;