Skip to content

Commit d31cd8b

Browse files
committed
change handles destruction order (based on the patch by Chris Jones) and fix typo
1 parent 5d80c94 commit d31cd8b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ext/oci8/oci8.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static void php_oci_init_global_handles(TSRMLS_D)
441441
static void php_oci_cleanup_global_handles(TSRMLS_D)
442442
{
443443
if (OCI_G(err)) {
444-
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) OCI_G(err), OCI_HTYPE_ENV));
444+
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) OCI_G(err), OCI_HTYPE_ERROR));
445445
OCI_G(err) = NULL;
446446
}
447447

@@ -1408,30 +1408,30 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC)
14081408
}
14091409
}
14101410

1411+
if (connection->svc && connection->session && connection->is_open) {
1412+
PHP_OCI_CALL(OCISessionEnd, (connection->svc, OCI_G(err), connection->session, (ub4) 0));
1413+
}
1414+
1415+
if (connection->session) {
1416+
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->session, OCI_HTYPE_SESSION));
1417+
}
1418+
14111419
if (connection->is_attached) {
14121420
PHP_OCI_CALL(OCIServerDetach, (connection->server, OCI_G(err), OCI_DEFAULT));
14131421
}
14141422

1423+
if (connection->svc) {
1424+
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX));
1425+
}
1426+
14151427
if (connection->err) {
14161428
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->err, (ub4) OCI_HTYPE_ERROR));
14171429
}
1418-
1419-
if (connection->session) {
1420-
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->session, OCI_HTYPE_SESSION));
1421-
}
14221430

14231431
if (connection->server) {
14241432
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->server, (ub4) OCI_HTYPE_SERVER));
14251433
}
14261434

1427-
if (connection->svc) {
1428-
if (connection->session && connection->is_open) {
1429-
PHP_OCI_CALL(OCISessionEnd, (connection->svc, OCI_G(err), connection->session, (ub4) 0));
1430-
}
1431-
1432-
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX));
1433-
}
1434-
14351435
if (connection->env) {
14361436
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->env, OCI_HTYPE_ENV));
14371437
}

0 commit comments

Comments
 (0)