@@ -351,8 +351,21 @@ static void _php_db2_set_symbol(char * varname, zval *var)
351
351
}
352
352
/* }}} */
353
353
354
+ /* {{{ Murmur hash implementation (for persistent key hash)
355
+ */
354
356
357
+ static unsigned int _php_db2_MurmurOAAT32 (const char * key )
358
+ {
359
+ unsigned int h = 3323198485 ;
360
+ for (;* key ;++ key ) {
361
+ h ^= * key ;
362
+ h *= 0x5bd1e995 ;
363
+ h ^= h >> 15 ;
364
+ }
365
+ return h ;
366
+ }
355
367
368
+ /* }}} */
356
369
357
370
#ifdef PASE /* IBM i meta change ""->NULL */
358
371
static void _php_db2_meta_helper (SQLCHAR * * qualifier , size_t * qualifier_len ,
@@ -2313,6 +2326,7 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2313
2326
int reused = 0 ;
2314
2327
int hKeyLen = 0 ;
2315
2328
char * hKey = NULL ;
2329
+ unsigned int password_hashed ;
2316
2330
char server [2048 ];
2317
2331
int attr = SQL_TRUE ;
2318
2332
size_t database_len ;
@@ -2354,10 +2368,13 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2354
2368
/* Check if we already have a connection for this userID & database combination */
2355
2369
if (isPersistent ) {
2356
2370
zend_resource * entry ;
2357
- hKeyLen = strlen (database ) + strlen (uid ) + 8 ;
2371
+ hKeyLen = strlen (database ) + strlen (uid ) +
2372
+ sizeof ("__db2_..FFFFFFFF" ); /* constant part; includes null */
2358
2373
hKey = (char * ) ecalloc (1 , hKeyLen );
2359
2374
2360
- sprintf (hKey , "__db2_%s.%s" , uid , database );
2375
+ /* XXX: How do we include the options (array) in here too? */
2376
+ password_hashed = _php_db2_MurmurOAAT32 (password );
2377
+ snprintf (hKey , hKeyLen , "__db2_%s.%s.%08x" , uid , database , password_hashed );
2361
2378
temp = zend_hash_str_find_ptr (& EG (persistent_list ), hKey , hKeyLen );
2362
2379
if ( temp && temp -> type == le_pconn_struct ) {
2363
2380
conn_res = * pconn_res = (conn_handle * )temp -> ptr ;
0 commit comments