diff options
| author | Thies C. Arntzen <thies@php.net> | 1999-08-18 16:48:59 +0000 | 
|---|---|---|
| committer | Thies C. Arntzen <thies@php.net> | 1999-08-18 16:48:59 +0000 | 
| commit | c1218de0d2403d0578111db1439720fe6d8a5de5 (patch) | |
| tree | 6c3bbd3630666665f1ab2540f10ad6de4895390f | |
| parent | 3f48a5524d408dd02633dfa4247759981c85d64c (diff) | |
| download | php-git-c1218de0d2403d0578111db1439720fe6d8a5de5.tar.gz | |
ZTS
| -rw-r--r-- | ext/oci8/oci8.c | 25 | ||||
| -rw-r--r-- | ext/oracle/oracle.c | 67 | ||||
| -rw-r--r-- | ext/oracle/php3_oracle.h | 1 | 
3 files changed, 64 insertions, 29 deletions
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 62761e9e01..28095aa38a 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -296,14 +296,20 @@ 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);  + +	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 @@ PHP_MINIT_FUNCTION(oci)  	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 @@ PHP_MINIT_FUNCTION(oci)      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;  } diff --git a/ext/oracle/oracle.c b/ext/oracle/oracle.c index 1420fe0901..837f70cb20 100644 --- a/ext/oracle/oracle.c +++ b/ext/oracle/oracle.c @@ -97,6 +97,7 @@ int ora_set_param_values(oraCursor *cursor, int isout);  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 @@ static int _close_oracur(oraCursor *cur)  	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 @@ PHP_MINIT_FUNCTION(oracle)  	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 @@ void php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAMETERS, int persistent)  		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 @@ void php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAMETERS, int persistent)  			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 @@ void php3_Ora_Do_Logon(INTERNAL_FUNCTION_PARAMETERS, int persistent)  		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 @@ PHP_FUNCTION(ora_logoff)  	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 @@ ora_get_conn(HashTable *list,HashTable *plist,int ind)  	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 @@ ora_get_conn(HashTable *list,HashTable *plist,int ind)  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 @@ ora_get_cursor(HashTable *list, int ind)  	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 @@ void ora_del_cursor(HashTable *list, int ind)  	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;  	} diff --git a/ext/oracle/php3_oracle.h b/ext/oracle/php3_oracle.h index 6a6e3a6600..b0c113dd09 100644 --- a/ext/oracle/php3_oracle.h +++ b/ext/oracle/php3_oracle.h @@ -124,7 +124,6 @@ typedef struct {  	long max_links;  	long num_persistent;  	long num_links; -	int le_conn, le_pconn, le_cursor;  	HashTable *conns;  } php_ora_globals;  | 
