cvs: php4 /ext/ingres_ii ii.c ii.h
| From: | H�not David | Date: | Fri, 29 Sep 2000 09:29:02 +0000 |
| Subject: | cvs: php4 /ext/ingres_ii ii.c ii.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1875@lists.php.net to get a copy of this message | ||
henot Fri Sep 29 02:29:02 2000 EDT
Modified files:
/php4/ext/ingres_ii ii.c ii.h
Log:
Added clean up code for persistent connections to avoid some problems with
autocommit.
Index: php4/ext/ingres_ii/ii.c
diff -u php4/ext/ingres_ii/ii.c:1.9 php4/ext/ingres_ii/ii.c:1.10
--- php4/ext/ingres_ii/ii.c:1.9 Sat Aug 26 07:24:32 2000
+++ php4/ext/ingres_ii/ii.c Fri Sep 29 02:29:02 2000
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ii.c,v 1.9 2000/08/26 14:24:32 andi Exp $ */
+/* $Id: ii.c,v 1.10 2000/09/29 09:29:02 henot Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -172,6 +172,42 @@
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 @@
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 @@
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 @@
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 @@
RETURN_FALSE;
}
+ ii_link->autocommit = (ii_link->autocommit ? 0 : 1);
ii_link->tranHandle = autoParm.ac_tranHandle;
RETURN_TRUE;
}
Index: php4/ext/ingres_ii/ii.h
diff -u php4/ext/ingres_ii/ii.h:1.2 php4/ext/ingres_ii/ii.h:1.3
--- php4/ext/ingres_ii/ii.h:1.2 Fri Aug 25 08:56:40 2000
+++ php4/ext/ingres_ii/ii.h Fri Sep 29 02:29:02 2000
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ii.h,v 1.2 2000/08/25 15:56:40 henot Exp $ */
+/* $Id: ii.h,v 1.3 2000/09/29 09:29:02 henot Exp $ */
#ifndef II_H
#define II_H
@@ -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 _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);