fmk Mon Sep 5 01:03:23 2005 EDT Modified files: (Branch: PHP_4_4) /php-src/ext/mssql php_mssql.c Log: Fix for #34369 Add extra parameter to mssql_connect to force a new connection http://cvs.php.net/diff.php/php-src/ext/mssql/php_mssql.c?r1=1.86.2.44&r2=1.86.2.44.2.1&ty=u Index: php-src/ext/mssql/php_mssql.c diff -u php-src/ext/mssql/php_mssql.c:1.86.2.44 php-src/ext/mssql/php_mssql.c:1.86.2.44.2.1 --- php-src/ext/mssql/php_mssql.c:1.86.2.44 Tue Apr 12 13:46:45 2005 +++ php-src/ext/mssql/php_mssql.c Mon Sep 5 01:03:21 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mssql.c,v 1.86.2.44 2005/04/12 17:46:45 fmk Exp $ */ +/* $Id: php_mssql.c,v 1.86.2.44.2.1 2005/09/05 05:03:21 fmk Exp $ */ #ifdef COMPILE_DL_MSSQL #define HAVE_MSSQL 1 @@ -376,7 +376,7 @@ { char *user, *passwd, *host; char *hashed_details; - int hashed_details_length; + int hashed_details_length, new_link = 0; mssql_link mssql, *mssql_ptr; char buffer[32]; @@ -434,6 +434,25 @@ sprintf(hashed_details,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); /* SAFE */ } break; + case 4: { + zval **yyhost,**yyuser,**yypasswd, **yynew_link; + + if (zend_get_parameters_ex(4, &yyhost, &yyuser, &yypasswd, &yynew_link) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(yyhost); + convert_to_string_ex(yyuser); + convert_to_string_ex(yypasswd); + convert_to_long_ex(yynew_link); + host = Z_STRVAL_PP(yyhost); + user = Z_STRVAL_PP(yyuser); + passwd = Z_STRVAL_PP(yypasswd); + new_link = Z_LVAL_PP(yynew_link); + hashed_details_length = Z_STRLEN_PP(yyhost)+Z_STRLEN_PP(yyuser)+Z_STRLEN_PP(yypasswd)+5+3; + hashed_details = (char *) emalloc(hashed_details_length+1); + sprintf(hashed_details,"mssql_%s_%s_%s",Z_STRVAL_PP(yyhost),Z_STRVAL_PP(yyuser),Z_STRVAL_PP(yypasswd)); /* SAFE */ + } + break; default: WRONG_PARAM_COUNT; break; @@ -483,7 +502,7 @@ list_entry *le; /* try to find if we already have this link in our persistent list */ - if (zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_length + 1, (void **) &le)==FAILURE) { /* we don't */ + if (new_link || zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_length + 1, (void **) &le)==FAILURE) { /* we don't */ list_entry new_le; if (MS_SQL_G(max_links) != -1 && MS_SQL_G(num_links) >= MS_SQL_G(max_links)) { @@ -596,7 +615,7 @@ * if it doesn't, open a new mssql link, add it to the resource list, * and add a pointer to it with hashed_details as the key. */ - if (zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length + 1,(void **) &index_ptr)==SUCCESS) { + if (!new_link && zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length + 1,(void **) &index_ptr)==SUCCESS) { int type,link; void *ptr; @@ -686,7 +705,7 @@ return MS_SQL_G(default_link); } -/* {{{ proto int mssql_connect([string servername [, string username [, string password]]]) +/* {{{ proto int mssql_connect([string servername [, string username [, string password [, bool new_link]]]]) Establishes a connection to a MS-SQL server */ PHP_FUNCTION(mssql_connect) { @@ -695,7 +714,7 @@ /* }}} */ -/* {{{ proto int mssql_pconnect([string servername [, string username [, string password]]]) +/* {{{ proto int mssql_pconnect([string servername [, string username [, string password [, bool new_link]]]]) Establishes a persistent connection to a MS-SQL server */ PHP_FUNCTION(mssql_pconnect) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php