mirror of
https://github.com/php/php-src.git
synced 2024-11-26 19:33:55 +08:00
Added clean up code for persistent connections to avoid some problems with
autocommit.
This commit is contained in:
parent
5844b74e22
commit
a68a224efd
@ -172,6 +172,42 @@ static void _close_ii_plink(II_LINK *link)
|
||||
IIG(num_persistent)--;
|
||||
}
|
||||
|
||||
/* cleans up the given persistent link.
|
||||
used when the request ends to 'refresh' the link for use
|
||||
by the next request
|
||||
*/
|
||||
static void _clean_ii_plink(II_LINK *link)
|
||||
{
|
||||
IIAPI_AUTOPARM autoParm;
|
||||
IILS_FETCH();
|
||||
|
||||
if(link->autocommit) {
|
||||
|
||||
if(link->stmtHandle && _close_statement(link)) {
|
||||
php_error(E_WARNING,"Ingres II: Unable to close statement !!");
|
||||
}
|
||||
|
||||
autoParm.ac_genParm.gp_callback = NULL;
|
||||
autoParm.ac_genParm.gp_closure = NULL;
|
||||
autoParm.ac_connHandle = link->connHandle;
|
||||
autoParm.ac_tranHandle = link->tranHandle;
|
||||
|
||||
IIapi_autocommit(&autoParm);
|
||||
ii_sync(&(autoParm.ac_genParm));
|
||||
|
||||
if(ii_success(&(autoParm.ac_genParm))==II_FAIL) {
|
||||
php_error(E_WARNING,"Ingres II: Unable to disable autocommit");
|
||||
}
|
||||
|
||||
link->autocommit = 0;
|
||||
link->tranHandle = NULL;
|
||||
}
|
||||
|
||||
if(link->tranHandle && _rollback_transaction(link)) {
|
||||
php_error(E_WARNING,"Ingres II: Unable to rollback transaction !!");
|
||||
}
|
||||
}
|
||||
|
||||
/* sets the default link
|
||||
*/
|
||||
static void php_ii_set_default_link(int id)
|
||||
@ -212,7 +248,7 @@ PHP_MINIT_FUNCTION(ii)
|
||||
REGISTER_INI_ENTRIES();
|
||||
|
||||
le_ii_link = register_list_destructors(_close_ii_link,NULL);
|
||||
le_ii_plink = register_list_destructors(NULL,_close_ii_plink);
|
||||
le_ii_plink = register_list_destructors(_clean_ii_plink,_close_ii_plink);
|
||||
|
||||
IIG(num_persistent) = 0;
|
||||
|
||||
@ -444,6 +480,7 @@ static void php_ii_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
|
||||
link->stmtHandle = NULL;
|
||||
link->fieldCount = 0;
|
||||
link->descriptor = NULL;
|
||||
link->autocommit = 0;
|
||||
|
||||
/* hash it up */
|
||||
new_le.type = le_ii_plink;
|
||||
@ -526,6 +563,7 @@ static void php_ii_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
|
||||
link->stmtHandle = NULL;
|
||||
link->fieldCount = 0;
|
||||
link->descriptor = NULL;
|
||||
link->autocommit = 0;
|
||||
|
||||
/* add it to the list */
|
||||
ZEND_REGISTER_RESOURCE(return_value, link, le_ii_link);
|
||||
@ -1324,6 +1362,7 @@ PHP_FUNCTION(ingres_autocommit)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ii_link->autocommit = (ii_link->autocommit ? 0 : 1);
|
||||
ii_link->tranHandle = autoParm.ac_tranHandle;
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "iiapi.h"
|
||||
|
||||
typedef struct _II_LINK {
|
||||
int autocommit;
|
||||
II_PTR connHandle;
|
||||
II_PTR tranHandle;
|
||||
II_PTR stmtHandle;
|
||||
@ -45,6 +46,7 @@ static int _close_statement(II_LINK *link);
|
||||
static int _rollback_transaction(II_LINK *link);
|
||||
static void _close_ii_link(II_LINK *link);
|
||||
static void _close_ii_plink(II_LINK *link);
|
||||
static void _clean_ii_plink(II_LINK *link);
|
||||
static int php_ii_get_default_link(INTERNAL_FUNCTION_PARAMETERS IILS_DC);
|
||||
static void php_ii_set_default_link(int id);
|
||||
static void php_ii_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent);
|
||||
|
Loading…
Reference in New Issue
Block a user