CVS update: php3/functions

From: Date: Tue, 01 Jun 1999 08:11:04 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-6350@lists.php.net to get a copy of this message
Date: Tuesday June 1, 1999 @ 4:11 Author: thies Update of /repository/php3/functions In directory php:/tmp/cvs-serv17949/functions Modified Files: oracle.c oracle.h Log Message: this fixes the shutdown of cursors AFTER the connection has already beed closed. the same problem needs to get fixed in some other modules (unified_odbc), i think! Index: php3/functions/oracle.c diff -u php3/functions/oracle.c:1.107 php3/functions/oracle.c:1.108 --- php3/functions/oracle.c:1.107 Mon May 31 10:54:18 1999 +++ php3/functions/oracle.c Tue Jun 1 04:11:04 1999 @@ -191,15 +191,12 @@ conn->open = 0; - /* zeev says, this is a no-no (thies 990430) - _php3_hash_apply(ORACLE_GLOBAL(php3_oracle_module).resource_list, - (int (*)(void *))_cursors_cleanup); - */ - ologof(&conn->lda); ORACLE_GLOBAL(php3_oracle_module).num_links--; efree(conn); + _php3_hash_del(ORACLE_GLOBAL(php3_oracle_module).conns,(void*)&conn,sizeof(void*)); + return 1; } @@ -209,16 +206,13 @@ conn->open = 0; - /* zeev says, this is a no-no (thies 990430) - _php3_hash_apply(ORACLE_GLOBAL(php3_oracle_module).resource_plist, - (int (*)(void *))_cursors_cleanup); - */ - ologof(&conn->lda); free(conn); ORACLE_GLOBAL(php3_oracle_module).num_links--; ORACLE_GLOBAL(php3_oracle_module).num_persistent--; + _php3_hash_del(ORACLE_GLOBAL(php3_oracle_module).conns,(void*)&conn,sizeof(void*)); + return 1; } @@ -258,40 +252,14 @@ efree(cur->columns); cur->columns = NULL; } -#if 0 + if (cur->open){ oraConnection *db_conn; - int alive = 0, type; - /* 1st check if our connection is still there */ - - /* XXX THIS CODE DOESN'T WORK, we need to keep track of closed connections somehow ourself - unified_odbs calls hash_apply, which is wrong as well! - */ - db_conn = (oraConnection *)php3_list_do_find(ORACLE_GLOBAL(php3_oracle_module).list,cur->conn_id, &type); - if (db_conn && (type == ORACLE_GLOBAL(php3_oracle_module).le_conn)) { - alive = 1; - } - - if (! alive) { - db_conn = (oraConnection *)php3_list_do_find(ORACLE_GLOBAL(php3_oracle_module).plist,cur->conn_id, &type); - if (db_conn && (type == ORACLE_GLOBAL(php3_oracle_module).le_pconn)) { - alive = 1; - } - } - - if (alive) { + if (_php3_hash_find(ORACLE_GLOBAL(php3_oracle_module).conns,(void*)&(cur->conn_ptr),sizeof(void*),(void **)&db_conn) == SUCCESS) { oclose(&cur->cda); - } - - cur->open = 0; + } } -#else - /* XXX THIS IS WRONG, MAY CAUSE PROBLEMS (closing a cursor that belongs to a closed connection) !!! */ - if (cur->open){ - oclose(&cur->cda); - } -#endif efree(cur); } @@ -345,6 +313,9 @@ ORACLE_GLOBAL(php3_oracle_module).le_pconn = register_list_destructors(NULL, _close_orapconn); + ORACLE_GLOBAL(php3_oracle_module).conns = malloc(sizeof(HashTable)); + _php3_hash_init(ORACLE_GLOBAL(php3_oracle_module).conns, 13, NULL, NULL, 1); + REGISTER_LONG_CONSTANT("ORA_BIND_INOUT", 0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ORA_BIND_IN", 1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ORA_BIND_OUT", 2, CONST_CS | CONST_PERSISTENT); @@ -391,8 +362,11 @@ } PHP3_MUTEX_UNLOCK(oracle_mutex); #endif - return SUCCESS; + _php3_hash_destroy(ORACLE_GLOBAL(php3_oracle_module).conns); + free(ORACLE_GLOBAL(php3_oracle_module).conns); + + return SUCCESS; } int php3_rshutdown_oracle(SHUTDOWN_FUNC_ARGS) @@ -452,10 +426,6 @@ int hashed_len, len, id; ORACLE_TLS_VARS; - /* we need those for shutdown */ - ORACLE_GLOBAL(php3_oracle_module).list = list; - ORACLE_GLOBAL(php3_oracle_module).plist = plist; - if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; } @@ -560,7 +530,7 @@ } ORACLE_GLOBAL(php3_oracle_module).num_links++; - + } else { int type; @@ -596,6 +566,14 @@ return_value->value.lval = id; } } + + _php3_hash_add(ORACLE_GLOBAL(php3_oracle_module).conns, + (void*)&db_conn, + sizeof(void*), + (void*)&db_conn, + sizeof(void*), + NULL); + efree(hashed_details); return_value->type = IS_LONG; } @@ -812,6 +790,7 @@ RETURN_FALSE; } if (!(cursor = ora_get_cursor(list, argv[0]->value.lval))){ + efree(query); RETURN_FALSE; } @@ -1675,6 +1654,7 @@ ora_get_cursor(HashTable *list, int ind) { oraCursor *cursor; + oraConnection *db_conn; int type; ORACLE_TLS_VARS; @@ -1683,6 +1663,12 @@ php3_error(E_WARNING, "Invalid cursor index %d", ind); return NULL; } + + if (_php3_hash_find(ORACLE_GLOBAL(php3_oracle_module).conns,(void*)&(cursor->conn_ptr),sizeof(void*),(void **)&db_conn) == FAILURE) { + php3_error(E_WARNING, "Connection already closed for cursor index %d", ind); + return NULL; + } + return cursor; } Index: php3/functions/oracle.h diff -u php3/functions/oracle.h:1.39 php3/functions/oracle.h:1.40 --- php3/functions/oracle.h:1.39 Sat May 29 06:12:49 1999 +++ php3/functions/oracle.h Tue Jun 1 04:11:04 1999 @@ -1,4 +1,4 @@ -/* $Id: oracle.h,v 1.39 1999/05/29 10:12:49 thies Exp $ */ +/* $Id: oracle.h,v 1.40 1999/06/01 08:11:04 thies Exp $ */ #ifndef _PHP3_ORACLE_H #define _PHP3_ORACLE_H @@ -107,8 +107,7 @@ long num_persistent; long num_links; int le_conn, le_pconn, le_cursor; - HashTable *list; - HashTable *plist; + HashTable *conns; } oracle_module; extern void php3_Ora_Bind(INTERNAL_FUNCTION_PARAMETERS);

« previous php.dev (#6350) next »