diff options
author | Thies C. Arntzen <thies@php.net> | 1999-10-05 16:06:54 +0000 |
---|---|---|
committer | Thies C. Arntzen <thies@php.net> | 1999-10-05 16:06:54 +0000 |
commit | 7fe8812d3ea52a51c8bfcc8b644ca9ad2c081a76 (patch) | |
tree | 84cedc6df09a9e9f2280df567e46abd90685b681 /ext/oci8 | |
parent | f48a4916ea11620687215c29e6558e6000b898d9 (diff) | |
download | php-git-7fe8812d3ea52a51c8bfcc8b644ca9ad2c081a76.tar.gz |
use reference counting for emulating child<->parent (cursor<->connection) relationships.
Diffstat (limited to 'ext/oci8')
-rw-r--r-- | ext/oci8/oci8.c | 42 | ||||
-rw-r--r-- | ext/oci8/php3_oci8.h | 2 |
2 files changed, 13 insertions, 31 deletions
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 583f6c3a08..8160cd6d10 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -306,9 +306,6 @@ static void php_oci_init_globals(php_oci_globals *oci_globals) OCI(server) = malloc(sizeof(HashTable)); zend_hash_init(OCI(server), 13, NULL, NULL, 1); - OCI(conns) = malloc(sizeof(HashTable)); - zend_hash_init(OCI(conns), 13, NULL, NULL, 1); - OCIEnvInit(&OCI(pEnv), OCI_DEFAULT, 0, NULL); OCIHandleAlloc(OCI(pEnv), (dvoid **)&OCI(pError), @@ -336,9 +333,6 @@ PHP_MINIT_FUNCTION(oci) OCI(server) = malloc(sizeof(HashTable)); zend_hash_init(OCI(server), 13, NULL, NULL, 1); - OCI(conns) = malloc(sizeof(HashTable)); - zend_hash_init(OCI(conns), 13, NULL, NULL, 1); - OCIEnvInit(&OCI(pEnv), OCI_DEFAULT, 0, NULL); OCIHandleAlloc(OCI(pEnv), (dvoid **)&OCI(pError), @@ -451,11 +445,9 @@ PHP_MSHUTDOWN_FUNCTION(oci) zend_hash_destroy(OCI(user)); zend_hash_destroy(OCI(server)); - zend_hash_destroy(OCI(conns)); free(OCI(user)); free(OCI(server)); - free(OCI(conns)); OCIHandleFree((dvoid *)OCI(pEnv), OCI_HTYPE_ENV); @@ -547,16 +539,12 @@ static int _oci_column_dtor(void *data) { oci_out_column *column = (oci_out_column *) data; - oci_connection *db_conn; - OCILS_FETCH(); oci_debug("START _oci_column_dtor: %s",column->name); if (column->data) { if (column->is_descr) { - if (zend_hash_find(OCI(conns),(void*)&(column->statement->conn),sizeof(void*),(void **)&db_conn) == SUCCESS) { - zend_hash_index_del(column->statement->conn->descriptors,(int) column->data); - } + zend_hash_index_del(column->statement->conn->descriptors,(int) column->data); } else { if (column->data) { efree(column->data); @@ -575,15 +563,11 @@ _oci_column_dtor(void *data) /* }}} */ /* {{{ _oci_statement_dtor() */ - + static void _oci_statement_dtor(oci_statement *statement) { - if (! statement) { - return; - } - - oci_debug("_oci_statement_dtor: id=%d last_query=\"%s\"",statement->id,SAFE_STRING(statement->last_query)); + oci_debug("START _oci_statement_dtor: id=%d last_query=\"%s\"",statement->id,SAFE_STRING(statement->last_query)); if (statement->pStmt) { OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT); @@ -614,6 +598,10 @@ _oci_statement_dtor(oci_statement *statement) efree(statement->defines); } + zend_list_delete(statement->conn->id); /* delete one ref from the connection */ + + oci_debug("END _oci_statement_dtor: id=%d",statement->id); + efree(statement); } @@ -627,12 +615,8 @@ _oci_connection_dtor(oci_connection *connection) as the connection is "only" a in memory service context we do not disconnect from oracle. */ - OCILS_FETCH(); - oci_debug("START _oci_connection_dtor: id=%d",connection->id); - zend_hash_del(OCI(conns),(void*)&connection,sizeof(void*)); - if (connection->descriptors) { zend_hash_destroy(connection->descriptors); efree(connection->descriptors); @@ -961,6 +945,8 @@ static oci_statement *oci_parse(oci_connection *connection, char *query, int len statement->id, statement->conn->id); + zend_list_addref(statement->conn->id); + return statement; } @@ -2153,7 +2139,7 @@ static void oci_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent,int exclu */ - connection->id = php3_list_insert(connection, le_conn); + connection->id = zend_list_insert(connection, le_conn); connection->descriptors = emalloc(sizeof(HashTable)); if (!connection->descriptors || @@ -2165,15 +2151,13 @@ static void oci_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent,int exclu oci_debug("oci_do_connect: id=%d",connection->id); - zend_hash_add(OCI(conns),(void*)&connection,sizeof(void*),(void*)&connection,sizeof(void*),NULL); - RETURN_RESOURCE(connection->id); CLEANUP: oci_debug("oci_do_connect: FAILURE -> CLEANUP called"); if (connection->id) { - php3_list_delete(connection->id); + zend_list_delete(connection->id); } else { _oci_connection_dtor(connection); } @@ -3155,7 +3139,7 @@ PHP_FUNCTION(ocifreestatement) OCI_GET_STMT(statement,stmt); - php3_list_delete(statement->id); + zend_list_delete(statement->id); RETURN_TRUE; } @@ -3182,7 +3166,7 @@ PHP_FUNCTION(ocilogoff) zend_hash_apply(list,(int (*)(void *))_stmt_cleanup); - if (php3_list_delete(connection->id) == SUCCESS) { + if (zend_list_delete(connection->id) == SUCCESS) { RETURN_TRUE; } else { RETURN_FALSE; diff --git a/ext/oci8/php3_oci8.h b/ext/oci8/php3_oci8.h index d6d2e0d55f..3df40bcdd0 100644 --- a/ext/oci8/php3_oci8.h +++ b/ext/oci8/php3_oci8.h @@ -168,8 +168,6 @@ typedef struct { int user_num; HashTable *user; - HashTable *conns; - OCIEnv *pEnv; } php_oci_globals; |