CVS update: php3/functions
| From: | thies | Date: | Tue, 20 Apr 1999 11:33:47 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-5149@lists.php.net to get a copy of this message | ||
Date: Tuesday April 20, 1999 @ 7:33
Author: thies
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv23166/functions
Modified Files:
oci8.c php3_oci8.h
Log Message:
we no longer crash on broken connections...
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.81 php3/functions/oci8.c:1.82
*** php3/functions/oci8.c:1.81 Mon Apr 19 15:08:40 1999
--- php3/functions/oci8.c Tue Apr 20 07:33:46 1999
***************
*** 33,42 ****
#define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
! /* $Id: oci8.c,v 1.81 1999/04/19 19:08:40 thies Exp $ */
/* TODO list:
*
* - Commit/Rollback testing.....
* - php.ini flags
* - Error mode (print or shut up?)
--- 33,43 ----
#define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
! /* $Id: oci8.c,v 1.82 1999/04/20 11:33:46 thies Exp $ */
/* TODO list:
*
+ * - better oracle-error handling.
* - Commit/Rollback testing.....
* - php.ini flags
* - Error mode (print or shut up?)
***************
*** 195,200 ****
--- 196,204 ----
/* define callback function */
static sb4 oci8_define_callback(dvoid *, OCIDefine *, ub4, dvoid **, ub4 **, ub1 *, dvoid **, ub2
**);
+ /* failover callback function */
+ static sb4 oci8_failover_callback(dvoid *svchp,dvoid* envhp,dvoid *fo_ctx,ub4 fo_type, ub4
fo_event);
+
/* }}} */
/* {{{ extension function prototypes */
***************
*** 775,782 ****
if (!connection || !OCI8_CONN_TYPE(type)) {
php3_error(E_WARNING, "%s: invalid connection %d", func, conn_ind);
return (oci8_connection *)NULL;
}
- return connection;
}
/* }}} */
--- 779,791 ----
if (!connection || !OCI8_CONN_TYPE(type)) {
php3_error(E_WARNING, "%s: invalid connection %d", func, conn_ind);
return (oci8_connection *)NULL;
+ }
+
+ if (connection->open) {
+ return connection;
+ } else {
+ return (oci8_connection *)NULL;
}
}
/* }}} */
***************
*** 793,800 ****
if (!statement || !OCI8_STMT_TYPE(type)) {
php3_error(E_WARNING, "%s: invalid statement %d", func, stmt_ind);
return (oci8_statement *)NULL;
}
- return statement;
}
/* }}} */
--- 802,814 ----
if (!statement || !OCI8_STMT_TYPE(type)) {
php3_error(E_WARNING, "%s: invalid statement %d", func, stmt_ind);
return (oci8_statement *)NULL;
+ }
+
+ if (statement->conn->open) {
+ return statement;
+ } else {
+ return (oci8_statement *)NULL;
}
}
/* }}} */
***************
*** 1023,1033 ****
NULL,
NULL,
mode));
! if (error) {
return 0;
}
-
if (stmttype == OCI_STMT_SELECT && (statement->executed == 0)) {
/* we only need to do the define step is this very statement is executed the first time! */
statement->executed++;
--- 1037,1055 ----
NULL,
NULL,
mode));
!
! switch (error) {
! case 0:
! break;
!
! case 3113: /* ORA-03113: end-of-file on communication channel */
! statement->conn->open = 0;
! statement->conn->session->open = 0;
! statement->conn->session->server->open = 0;
return 0;
+ break;
}
if (stmttype == OCI_STMT_SELECT && (statement->executed == 0)) {
/* we only need to do the define step is this very statement is executed the first time! */
statement->executed++;
***************
*** 1345,1351 ****
--- 1367,1450 ----
return loblen;
}
+
/* }}} */
+ /* {{{ oci8_failover_callback() */
+
+ static sb4
+ oci8_failover_callback(dvoid *svchp,
+ dvoid* envhp,
+ dvoid *fo_ctx,
+ ub4 fo_type,
+ ub4 fo_event)
+ {
+ /*
+ this stuff is from an oci sample - it will get cleaned up as soon as i understand it!!!
(thies@digicol.de 990420)
+ right now i cant get oracle to even call it;-(((((((((((
+ */
+
+ switch (fo_event)
+ {
+ case OCI_FO_BEGIN:
+ {
+ printf(" Failing Over ... Please stand by \n");
+ printf(" Failover type was found to be %s \n",
+ ((fo_type==OCI_FO_NONE) ? "NONE"
+ :(fo_type==OCI_FO_SESSION) ? "SESSION"
+ :(fo_type==OCI_FO_SELECT) ? "SELECT"
+ : "UNKNOWN!"));
+ printf(" Failover Context is :%s\n",
+ (fo_ctx?(char *)fo_ctx:"NULL POINTER!"));
+ break;
+ }
+
+ case OCI_FO_ABORT:
+ {
+ printf(" Failover aborted. Failover will not take place.\n");
+ break;
+ }
+
+ case OCI_FO_END:
+ {
+ printf(" Failover ended ...resuming services\n");
+ break;
+ }
+
+ case OCI_FO_REAUTH:
+ {
+ printf(" Failed over user. Resuming services\n");
+
+ /* Application can check the OCI_ATTR_SESSION attribute of
+ the service handle to find out the user being
+ re-authenticated.
+
+ After this, the application can replay any ALTER SESSION
+ commands associated with this session. These must have
+ been saved by the application in the fo_ctx
+ */
+ break;
+ }
+
+
+ case OCI_FO_ERROR:
+ {
+ printf(" Failover error gotten. Sleeping...\n");
+ sleep(3);
+ /* cannot find this blody define !!! return OCI_FO_RETRY; */
+ break;
+ }
+
+ default:
+ {
+ printf("Bad Failover Event: %ld.\n", fo_event);
+ break;
+ }
+ }
+
+ return 0;
+ }
+
+ /* }}} */
/* {{{ oci8_define_callback() */
static sb4
***************
*** 1693,1710 ****
oci8_debug("oci8_open_user new sess=%d
user=%s",session->num,session->hashed_details);
return session;
CLEANUP:
! if (hashed_details) {
! free(hashed_details);
! }
!
! if (session) {
! _oci8_close_user(session);
! }
!
! efree(session);
return 0;
}
--- 1792,1803 ----
oci8_debug("oci8_open_user new sess=%d
user=%s",session->num,session->hashed_details);
+ session->open = 1;
+
return session;
CLEANUP:
! _oci8_close_user(session);
return 0;
}
***************
*** 1758,1771 ****
oci8_error(session->pError, "_oci8_close_user: OCIAttrSet OCI_ATTR_SESSION",
error);
}
! error = OCISessionEnd(svchp,
! session->pError,
! session->pSession,
! (ub4) 0);
! if (error != OCI_SUCCESS) {
! oci8_error(session->pError, "_oci8_close_user: OCISessionEnd", error);
}
OCIHandleFree((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX);
if (session->pSession)
--- 1851,1869 ----
oci8_error(session->pError, "_oci8_close_user: OCIAttrSet OCI_ATTR_SESSION",
error);
}
! if (session->open) {
! error = OCISessionEnd(svchp,
! session->pError,
! session->pSession,
! (ub4) 0);
! if (error != OCI_SUCCESS) {
! oci8_error(session->pError, "_oci8_close_user: OCISessionEnd", error);
! }
! } else {
! oci8_debug("_oci8_close_user: Session was marked DEAD");
}
+
OCIHandleFree((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX);
if (session->pSession)
***************
*** 1878,1895 ****
sizeof(oci8_server),
(void **) &server);
oci8_debug("oci8_open_server new conn=%d dname=%s",server->num,server->dbname);
return server;
CLEANUP:
! if (hashed_details) {
! free(hashed_details);
! }
!
! if (server) {
! _oci8_close_server(server);
! }
return 0;
}
--- 1976,2004 ----
sizeof(oci8_server),
(void **) &server);
+ server->failover.fo_ctx = (dvoid *) server;
+ server->failover.callback_function = oci8_failover_callback;
+
+ error = OCIAttrSet((dvoid *)server->pServer,
+ (ub4) OCI_HTYPE_SERVER,
+ (dvoid *) &server->failover,
+ (ub4) 0,
+ (ub4) OCI_ATTR_FOCBK,
+ server->pError);
+
+ if (error) {
+ oci8_error(server->pError, "oci8_open_server OCIAttrSet OCI_ATTR_FOCBK", error);
+ goto CLEANUP;
+ }
+
oci8_debug("oci8_open_server new conn=%d dname=%s",server->num,server->dbname);
+ server->open = 1;
+
return server;
CLEANUP:
! _oci8_close_server(server);
return 0;
}
***************
*** 2063,2073 ****
--- 2172,2186 ----
goto CLEANUP;
}
+ connection->open = 1;
+
oci8_debug("oci8_do_connect: id=%d",connection->id);
RETURN_LONG(connection->id);
CLEANUP:
+ _oci8_close_conn(connection);
+
RETURN_FALSE;
}
Index: php3/functions/php3_oci8.h
diff -c php3/functions/php3_oci8.h:1.40 php3/functions/php3_oci8.h:1.41
*** php3/functions/php3_oci8.h:1.40 Mon Apr 19 15:08:40 1999
--- php3/functions/php3_oci8.h Tue Apr 20 07:33:46 1999
***************
*** 55,70 ****
--- 55,73 ----
typedef struct {
int num;
int persistent;
+ int open;
char *hashed_details;
int hashed_details_length;
char dbname[ 64 ];
OCIError *pError;
OCIServer *pServer;
+ OCIFocbkStruct failover;
} oci8_server;
typedef struct {
int num;
int persistent;
+ int open;
char *hashed_details;
int hashed_details_length;
oci8_server *server;
***************
*** 74,79 ****
--- 77,83 ----
typedef struct {
int id;
+ int open;
oci8_session *session;
OCISvcCtx *pServiceContext;
OCIError *pError;
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net