cvs: /php4 ChangeLog /php4/ext/oci8 oci8.c php3_oci8.h
| From: | Thies C . Arntzen | Date: | Tue, 05 Oct 1999 16:06:56 +0000 |
| Subject: | cvs: /php4 ChangeLog /php4/ext/oci8 oci8.c php3_oci8.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-5205@lists.php.net to get a copy of this message | ||
thies Tue Oct 5 12:06:56 1999 EDT
Modified files:
/php4 ChangeLog
/php4/ext/oci8 oci8.c php3_oci8.h
Log:
use reference counting for emulating child<->parent (cursor<->connection)
relationships.
Index: php4/ChangeLog
diff -u php4/ChangeLog:1.167 php4/ChangeLog:1.168
--- php4/ChangeLog:1.167 Tue Oct 5 10:35:58 1999
+++ php4/ChangeLog Tue Oct 5 12:06:52 1999
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? 1999, Version 4.0 Beta 3
+- OCI8 connections are now kept open as long as they are referenced (Thies)
- Cleaned up Directory-Module (Thies)
- Small fix in Ora_Close (Thies)
- Ported range() and shuffle() from PHP3 to PHP4 (Andrei)
Index: php4/ext/oci8/oci8.c
diff -u php4/ext/oci8/oci8.c:1.31 php4/ext/oci8/oci8.c:1.32
--- php4/ext/oci8/oci8.c:1.31 Thu Sep 30 04:41:45 1999
+++ php4/ext/oci8/oci8.c Tue Oct 5 12:06:54 1999
@@ -22,7 +22,7 @@
#define OCI_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
-/* $Id: oci8.c,v 1.31 1999/09/30 08:41:45 thies Exp $ */
+/* $Id: oci8.c,v 1.32 1999/10/05 16:06:54 thies Exp $ */
/* TODO list:
*
@@ -306,9 +306,6 @@
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 @@
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 @@
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 @@
_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_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 @@
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 @@
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 @@
statement->id,
statement->conn->id);
+ zend_list_addref(statement->conn->id);
+
return statement;
}
@@ -2153,7 +2139,7 @@
*/
- 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 @@
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 @@
OCI_GET_STMT(statement,stmt);
- php3_list_delete(statement->id);
+ zend_list_delete(statement->id);
RETURN_TRUE;
}
@@ -3182,7 +3166,7 @@
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;
Index: php4/ext/oci8/php3_oci8.h
diff -u php4/ext/oci8/php3_oci8.h:1.10 php4/ext/oci8/php3_oci8.h:1.11
--- php4/ext/oci8/php3_oci8.h:1.10 Thu Sep 30 04:41:45 1999
+++ php4/ext/oci8/php3_oci8.h Tue Oct 5 12:06:54 1999
@@ -168,8 +168,6 @@
int user_num;
HashTable *user;
- HashTable *conns;
-
OCIEnv *pEnv;
} php_oci_globals;