]> granicus.if.org Git - php/commitdiff
fix PECL bug #7827
authorAntony Dovgal <tony2001@php.net>
Sat, 5 Aug 2006 20:56:43 +0000 (20:56 +0000)
committerAntony Dovgal <tony2001@php.net>
Sat, 5 Aug 2006 20:56:43 +0000 (20:56 +0000)
add small optimization

ext/oci8/oci8.c

index 1b358928982783cfcbba79229335a7f284d8f387..1df805ff7f47eca70618608aed47d76d30247c23 100644 (file)
@@ -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);