cvs: /php4/ext/oci8 oci8.c /php4/ext/oracle oracle.c php3_oracle.h
| From: | Thies C . Arntzen | Date: | Wed, 18 Aug 1999 16:48:59 +0000 |
| Subject: | cvs: /php4/ext/oci8 oci8.c /php4/ext/oracle oracle.c php3_oracle.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-3553@lists.php.net to get a copy of this message | ||
thies Wed Aug 18 12:48:59 1999 EDT
Modified files:
/php4/ext/oci8 oci8.c
/php4/ext/oracle oracle.c php3_oracle.h
Log:
ZTS
Index: php4/ext/oci8/oci8.c
diff -u php4/ext/oci8/oci8.c:1.19 php4/ext/oci8/oci8.c:1.20
--- php4/ext/oci8/oci8.c:1.19 Wed Aug 18 08:51:51 1999
+++ php4/ext/oci8/oci8.c Wed Aug 18 12:48:56 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.19 1999/08/18 12:51:51 thies Exp $ */
+/* $Id: oci8.c,v 1.20 1999/08/18 16:48:56 thies Exp $ */
/* TODO list:
*
@@ -296,14 +296,20 @@
OCI(server) = malloc(sizeof(HashTable));
zend_hash_init(OCI(server), 13, NULL, NULL, 1);
+
+ OCIEnvInit(&OCI(pEnv), OCI_DEFAULT, 0, NULL);
+ OCIHandleAlloc(OCI(pEnv),
+ (dvoid **)&OCI(pError),
+ OCI_HTYPE_ERROR,
+ 0,
+ NULL);
+
}
#endif
PHP_MINIT_FUNCTION(oci)
{
- OCILS_FETCH();
ELS_FETCH();
-
#ifdef ZTS
oci_globals_id = ts_allocate_id(sizeof(php_oci_globals), php_oci_init_globals, NULL);
#else
@@ -315,6 +321,14 @@
OCI(server) = malloc(sizeof(HashTable));
zend_hash_init(OCI(server), 13, NULL, NULL, 1);
+
+ OCIEnvInit(&OCI(pEnv), OCI_DEFAULT, 0, NULL);
+ OCIHandleAlloc(OCI(pEnv),
+ (dvoid **)&OCI(pError),
+ OCI_HTYPE_ERROR,
+ 0,
+ NULL);
+
#endif
le_conn = register_list_destructors(_oci_close_conn, NULL);
@@ -370,13 +384,6 @@
OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
#endif
- OCIEnvInit(&OCI(pEnv), OCI_DEFAULT, 0, NULL);
- OCIHandleAlloc(OCI(pEnv),
- (dvoid **)&OCI(pError),
- OCI_HTYPE_ERROR,
- 0,
- NULL);
-
return SUCCESS;
}
Index: php4/ext/oracle/oracle.c
diff -u php4/ext/oracle/oracle.c:1.15 php4/ext/oracle/oracle.c:1.16
--- php4/ext/oracle/oracle.c:1.15 Wed Aug 18 11:39:45 1999
+++ php4/ext/oracle/oracle.c Wed Aug 18 12:48:57 1999
@@ -97,6 +97,7 @@
void php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAMETERS, int persistent);
+static int le_conn, le_pconn, le_cursor;
PHP_FUNCTION(ora_bind);
PHP_FUNCTION(ora_close);
@@ -283,12 +284,41 @@
return 1;
}
+#ifdef ZTS
+static void php_ora_init_globals(php_ora_globals *ora_globals)
+{
+ ELS_FETCH();
+
+ if (cfg_get_long("oracle.allow_persistent",
+ &ORA(allow_persistent))
+ == FAILURE) {
+ ORA(allow_persistent) = -1;
+ }
+ if (cfg_get_long("oracle.max_persistent",
+ &ORA(max_persistent))
+ == FAILURE) {
+ ORA(max_persistent) = -1;
+ }
+ if (cfg_get_long("oracle.max_links",
+ &ORA(max_links))
+ == FAILURE) {
+ ORA(max_links) = -1;
+ }
+
+ ORA(num_persistent) = 0;
+
+ ORA(conns) = malloc(sizeof(HashTable));
+ zend_hash_init(ORA(conns), 13, NULL, NULL, 1);
+}
+#endif
PHP_MINIT_FUNCTION(oracle)
{
ELS_FETCH();
- ORALS_FETCH();
+#ifdef ZTS
+ ora_globals_id = ts_allocate_id(sizeof(php_ora_globals), php_ora_init_globals, NULL);
+#else
if (cfg_get_long("oracle.allow_persistent",
&ORA(allow_persistent))
== FAILURE) {
@@ -307,15 +337,14 @@
ORA(num_persistent) = 0;
- ORA(le_cursor) =
- register_list_destructors(_close_oracur, NULL);
- ORA(le_conn) =
- register_list_destructors(_close_oraconn, NULL);
- ORA(le_pconn) =
- register_list_destructors(NULL, _close_orapconn);
ORA(conns) = malloc(sizeof(HashTable));
zend_hash_init(ORA(conns), 13, NULL, NULL, 1);
+#endif
+
+ le_cursor = register_list_destructors(_close_oracur, NULL);
+ le_conn = register_list_destructors(_close_oraconn, NULL);
+ le_pconn = register_list_destructors(NULL, _close_orapconn);
REGISTER_LONG_CONSTANT("ORA_BIND_INOUT", 0, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ORA_BIND_IN", 1, CONST_CS | CONST_PERSISTENT);
@@ -495,9 +524,9 @@
db_conn->open = 1;
if (persistent){
- /*new_le.type = ORA(le_pconn);
+ /*new_le.type = le_pconn;
new_le.ptr = db_conn;*/
- RETVAL_RESOURCE(php3_plist_insert(db_conn, ORA(le_pconn)));
+ RETVAL_RESOURCE(php3_plist_insert(db_conn, le_pconn));
new_index_ptr.ptr = (void *) return_value->value.lval;
#ifdef THREAD_SAFE
new_index_ptr.type = _php3_le_index_ptr();
@@ -515,7 +544,7 @@
ORA(num_persistent)++;
} else {
/* non persistent, simply add to list */
- RETVAL_RESOURCE(php3_list_insert(db_conn, ORA(le_conn)));
+ RETVAL_RESOURCE(php3_list_insert(db_conn, le_conn));
}
ORA(num_links)++;
@@ -536,8 +565,8 @@
id = (int) index_ptr->ptr;
db_conn = (oraConnection *)php3_plist_find(id, &type);
- if (db_conn && (type == ORA(le_conn) ||
- type == ORA(le_pconn))){
+ if (db_conn && (type == le_conn ||
+ type == le_pconn)){
if(!_ora_ping(db_conn)) {
/* XXX Reinitialize lda, hda ? */
#if HAS_OLOG
@@ -588,8 +617,8 @@
ind = (int)arg->value.lval;
conn = (oraConnection *)php3_list_find(ind, &type);
- if (!conn || (type != ORA(le_conn) &&
- type != ORA(le_pconn))) {
+ if (!conn || (type != le_conn &&
+ type != le_pconn)) {
return;
}
php3_list_delete(ind);
@@ -1637,11 +1666,11 @@
ORALS_FETCH();
conn = (oraConnection *)php3_list_find(ind, &type);
- if (conn && type == ORA(le_conn))
+ if (conn && type == le_conn)
return conn;
conn = (oraConnection *)php3_plist_find(ind, &type);
- if (conn && type == ORA(le_pconn))
+ if (conn && type == le_pconn)
return conn;
php_error(E_WARNING,"Bad Oracle connection number (%d)", ind);
@@ -1651,7 +1680,7 @@
int ora_add_cursor(HashTable *list, oraCursor *cursor)
{
ORALS_FETCH();
- return php3_list_insert(cursor, ORA(le_cursor));
+ return php3_list_insert(cursor, le_cursor);
}
static oraCursor *
@@ -1663,7 +1692,7 @@
ORALS_FETCH();
cursor = php3_list_find(ind, &type);
- if (!cursor || type != ORA(le_cursor)) {
+ if (!cursor || type != le_cursor) {
php_error(E_WARNING, "Invalid cursor index %d", ind);
return NULL;
}
@@ -1683,7 +1712,7 @@
ORALS_FETCH();
cursor = (oraCursor *) php3_list_find(ind, &type);
- if (!cursor || type != ORA(le_cursor)) {
+ if (!cursor || type != le_cursor) {
php_error(E_WARNING,"Can't find cursor %d",ind);
return;
}
Index: php4/ext/oracle/php3_oracle.h
diff -u php4/ext/oracle/php3_oracle.h:1.6 php4/ext/oracle/php3_oracle.h:1.7
--- php4/ext/oracle/php3_oracle.h:1.6 Tue Aug 17 10:40:27 1999
+++ php4/ext/oracle/php3_oracle.h Wed Aug 18 12:48:59 1999
@@ -1,4 +1,4 @@
-/* $Id: php3_oracle.h,v 1.6 1999/08/17 14:40:27 thies Exp $ */
+/* $Id: php3_oracle.h,v 1.7 1999/08/18 16:48:59 thies Exp $ */
/* synced with oracle.h,v 1.40 1999/06/01 08:11:04 thies Exp $ */
@@ -124,7 +124,6 @@
long max_links;
long num_persistent;
long num_links;
- int le_conn, le_pconn, le_cursor;
HashTable *conns;
} php_ora_globals;