fix PECL bug #7827

add small optimization - no need to do anything if hash lookup failed, just move along
This commit is contained in:
Antony Dovgal 2006-08-05 20:56:12 +00:00
parent ead46d043f
commit 688975a519

View File

@ -48,6 +48,7 @@
#include "php_oci8.h"
#include "php_oci8_int.h"
#include "zend_hash.h"
ZEND_DECLARE_MODULE_GLOBALS(oci)
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5)
@ -1001,6 +1002,13 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
smart_str_appendl_ex(&hashed_details, "oci8___", sizeof("oci8___") - 1, 0);
smart_str_appendl_ex(&hashed_details, username, username_len, 0);
smart_str_appendl_ex(&hashed_details, "__", sizeof("__") - 1, 0);
if (password_len) {
ulong password_hash;
password_hash = zend_inline_hash_func(password, password_len);
smart_str_append_unsigned_ex(&hashed_details, password_hash, 0);
}
smart_str_appendl_ex(&hashed_details, "__", sizeof("__") - 1, 0);
if (dbname) {
smart_str_appendl_ex(&hashed_details, dbname, dbname_len, 0);
}
@ -1037,14 +1045,17 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
}
if (!exclusive && !new_password) {
zend_bool found = 0;
if (persistent && zend_hash_find(&EG(persistent_list), hashed_details.c, hashed_details.len+1, (void **) &le) == SUCCESS) {
found = 1;
/* found */
if (le->type == le_pconnection) {
connection = (php_oci_connection *)le->ptr;
}
}
else if (!persistent && zend_hash_find(&EG(regular_list), hashed_details.c, hashed_details.len+1, (void **) &le) == SUCCESS) {
found = 1;
if (le->type == le_index_ptr) {
int type;
long link;
@ -1106,8 +1117,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
connection = NULL;
goto open;
}
}
else {
} else if (found) {
/* found something, but it's not a connection, delete it */
if (persistent) {
zend_hash_del(&EG(persistent_list), hashed_details.c, hashed_details.len+1);