From: Antony Dovgal Date: Sat, 5 Aug 2006 20:56:43 +0000 (+0000) Subject: fix PECL bug #7827 X-Git-Tag: php-5.2.0RC2~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1a42253d9834c8228b4ada1a3c85de4be086c6d;p=php fix PECL bug #7827 add small optimization --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 1b35892898..1df805ff7f 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) static PHP_GINIT_FUNCTION(oci); @@ -986,6 +987,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); } @@ -1022,14 +1030,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; @@ -1091,8 +1102,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);