From 688975a51927b081c95824f53aeae448aa071bc4 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Sat, 5 Aug 2006 20:56:12 +0000 Subject: [PATCH] fix PECL bug #7827 add small optimization - no need to do anything if hash lookup failed, just move along --- ext/oci8/oci8.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 097234738b..777e1f085d 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -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); -- 2.50.1