CVS update: php3/functions

From: Date: Wed, 05 May 1999 06:35:21 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-5371@lists.php.net to get a copy of this message
Date: Wednesday May 5, 1999 @ 2:35 Author: thies Update of /repository/php3/functions In directory php:/tmp/cvs-serv31410/functions Modified Files: oci8.c php3_oci8.h Log Message: ironed out the last leaks with persitent connections Index: php3/functions/oci8.c diff -u php3/functions/oci8.c:1.88 php3/functions/oci8.c:1.89 --- php3/functions/oci8.c:1.88 Wed May 5 01:53:59 1999 +++ php3/functions/oci8.c Wed May 5 02:35:20 1999 @@ -33,7 +33,7 @@ #define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */ -/* $Id: oci8.c,v 1.88 1999/05/05 05:53:59 thies Exp $ */ +/* $Id: oci8.c,v 1.89 1999/05/05 06:35:20 thies Exp $ */ /* TODO list: * @@ -475,7 +475,7 @@ free(OCI8_GLOBAL(php3_oci8_module).user); free(OCI8_GLOBAL(php3_oci8_module).server); - OCIHandleFree((dvoid *) &OCI8_GLOBAL(php3_oci8_module).pEnv, OCI_HTYPE_ENV); + OCIHandleFree((dvoid *)OCI8_GLOBAL(php3_oci8_module).pEnv, OCI_HTYPE_ENV); #ifdef THREAD_SAFE oci8_global_struct *oci8_globals; @@ -1673,7 +1673,7 @@ sword error; oci8_session *session = 0; OCISvcCtx *svchp = 0; - char *hashed_details = 0; + char *hashed_details; int hashed_details_length; OCI8_TLS_VARS; @@ -1690,7 +1690,7 @@ strlen(SAFE_STRING(password))+ strlen(SAFE_STRING(server->dbname)); - hashed_details = (char *) malloc(hashed_details_length+1); + hashed_details = (char *) emalloc(hashed_details_length+1); sprintf(hashed_details,"%s%s%s", SAFE_STRING(username), @@ -1705,7 +1705,7 @@ if (persistent) { session->persistent = 1; } - free(hashed_details); + efree(hashed_details); return session; } else { _oci8_close_user(session); @@ -1722,8 +1722,6 @@ session->persistent = persistent; session->server = server; - session->hashed_details = hashed_details; - session->hashed_details_length = hashed_details_length; /* allocate temporary Service Context */ error = OCIHandleAlloc(OCI8_GLOBAL(php3_oci8_module).pEnv, @@ -1811,27 +1809,29 @@ session->open = 1; - oci8_debug("oci8_open_user new sess=%d user=%s",session->num,session->hashed_details); + oci8_debug("oci8_open_user new sess=%d user=%s",session->num,username); if (exclusive) { - _php3_hash_next_index_insert(OCI8_GLOBAL(php3_oci8_module).user, - (void *) session, - sizeof(oci8_session), - (void **) &session); + _php3_hash_next_index_pointer_insert(OCI8_GLOBAL(php3_oci8_module).user, + (void *) session); } else { - _php3_hash_add(OCI8_GLOBAL(php3_oci8_module).user, - hashed_details, - hashed_details_length+1, - (void *) session, - sizeof(oci8_session), - (void **) &session); + _php3_hash_pointer_update(OCI8_GLOBAL(php3_oci8_module).user, + hashed_details, + hashed_details_length+1, + (void *) session); } + efree(hashed_details); + return session; CLEANUP: oci8_debug("oci8_open_user: FAILURE -> CLEANUP called"); + if (hashed_details) { + efree(hashed_details); + } + _oci8_close_user(session); return 0; @@ -1851,7 +1851,7 @@ return; } - oci8_debug("_oci8_close_user: logging-off sess=%d user=%s",session->num,session->hashed_details); + oci8_debug("_oci8_close_user: logging-off sess=%d",session->num); if (session->open) { /* Temporary Service Context */ @@ -1900,14 +1900,12 @@ OCIHandleFree((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX); - if (session->pSession) + if (session->pSession) { OCIHandleFree((dvoid *) session->pSession, (ub4) OCI_HTYPE_SESSION); + } - if (session->pError) + if (session->pError) { OCIHandleFree((dvoid *) session->pError, (ub4) OCI_HTYPE_ERROR); - - if (session->hashed_details) { - free(session->hashed_details); } free(session); @@ -1933,7 +1931,7 @@ { oci8_server *server = 0; sword error; - char *hashed_details = 0; + char *hashed_details; int hashed_details_length; OCI8_TLS_VARS; @@ -1947,20 +1945,19 @@ */ hashed_details_length = strlen(SAFE_STRING((char *)dbname)); - hashed_details = (char *) malloc(hashed_details_length+1); + hashed_details = (char *) emalloc(hashed_details_length+1); sprintf(hashed_details,"%s",SAFE_STRING((char *)dbname)); _php3_hash_find(OCI8_GLOBAL(php3_oci8_module).server, hashed_details, hashed_details_length+1, (void **) &server); if (server) { if (server->open) { - free(hashed_details); - /* if our new users uses this connection persistent, we're keeping it! */ if (persistent) { server->persistent = persistent; } - + + efree(hashed_details); return server; } else { /* server "died" in the meantime - try to reconnect! */ _oci8_close_server(server); @@ -1976,10 +1973,7 @@ server->persistent = persistent; - server->hashed_details = hashed_details; - server->hashed_details_length = hashed_details_length; - - strcpy(server->dbname,dbname); + server->dbname = strdup(SAFE_STRING(dbname)); OCIHandleAlloc(OCI8_GLOBAL(php3_oci8_module).pEnv, (dvoid **)&server->pError, @@ -2028,19 +2022,22 @@ oci8_debug("oci8_open_server new conn=%d dname=%s",server->num,server->dbname); - _php3_hash_update(OCI8_GLOBAL(php3_oci8_module).server, - hashed_details, - hashed_details_length+1, - (void *) server, - sizeof(oci8_server), - (void **) &server); + _php3_hash_pointer_update(OCI8_GLOBAL(php3_oci8_module).server, + hashed_details, + hashed_details_length+1, + (void *) server); + efree(hashed_details); return server; CLEANUP: oci8_debug("oci8_open_server: FAILURE -> CLEANUP called"); + if (hashed_details) { + efree(hashed_details); + } + _oci8_close_server(server); return 0; @@ -2078,16 +2075,18 @@ oci8_debug("_oci8_close_server: closind DEAD server"); } - if (server->pServer) + if (server->pServer) { OCIHandleFree((dvoid *) server->pServer, (ub4) OCI_HTYPE_SERVER); + } - if (server->pError) + if (server->pError) { OCIHandleFree((dvoid *) server->pError, (ub4) OCI_HTYPE_ERROR); + } - if (server->hashed_details) { - free(server->hashed_details); + if (server->dbname) { + free(server->dbname); } - + free(server); } Index: php3/functions/php3_oci8.h diff -u php3/functions/php3_oci8.h:1.43 php3/functions/php3_oci8.h:1.44 --- php3/functions/php3_oci8.h:1.43 Tue May 4 11:24:39 1999 +++ php3/functions/php3_oci8.h Wed May 5 02:35:20 1999 @@ -57,9 +57,7 @@ int num; int persistent; int open; - char *hashed_details; - int hashed_details_length; - char dbname[ 64 ]; + char *dbname; OCIError *pError; OCIServer *pServer; OCIFocbkStruct failover; @@ -69,8 +67,6 @@ int num; int persistent; int open; - char *hashed_details; - int hashed_details_length; oci8_server *server; OCIError *pError; OCISession *pSession; -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5371) next »