[svn:dbd-oracle] r15096 - dbd-oracle/branches/FAN
[email protected] Wed, 25 Jan 2012 04:47:13 -0800 (PST)
| Newsgroups | perl.dbd.oracle.changes |
|---|---|
| Message-ID | <[email protected]> |
Author: byterock
Date: Wed Jan 25 04:47:12 2012
New Revision: 15096
Modified:
dbd-oracle/branches/FAN/dbdimp.h
dbd-oracle/branches/FAN/oci8.c
Log:
some cleanup dropping the thread mutex attempt
Modified: dbd-oracle/branches/FAN/dbdimp.h
==============================================================================
--- dbd-oracle/branches/FAN/dbdimp.h (original)
+++ dbd-oracle/branches/FAN/dbdimp.h Wed Jan 25 04:47:12 2012
@@ -8,11 +8,12 @@
/* ====== define data types ====== */
-typedef struct ha_context_st ha_context_t;
+/*--------------------------FAN Callback Structure ---------------------*/
-struct ha_context_st {
- PerlInterpreter *ct_perl;
- SV *dbh;
+typedef struct ha_ctx_st ha_ctx_t;
+
+struct ha_ctx_st {
+ PerlInterpreter *ctx_perl;
imp_dbh_t *imp_dbh;
char *function;
};
@@ -69,7 +70,6 @@
char *driver_name;/*driver name user defined*/
ub4 driver_namel;
bool using_ha;
- ha_context_t *ha_context;
char *ha_function;
#endif
taf_callback_t *taf_callback;
Modified: dbd-oracle/branches/FAN/oci8.c
==============================================================================
--- dbd-oracle/branches/FAN/oci8.c (original)
+++ dbd-oracle/branches/FAN/oci8.c Wed Jan 25 04:47:12 2012
@@ -1301,23 +1301,13 @@
void
-hacb_fn( dvoid *ha_ctx, OCIEvent *eventhp) {
+ha_cbk( dvoid *ha_ctx, OCIEvent *eventhp) {
- ha_context_t *ctx =(ha_context_t*)ha_ctx;
- imp_dbh_t *imp_dbh = (imp_dbh_t*)ctx->imp_dbh;
- pthread_mutex_t mutex;
- pthread_mutex_init(&mutex, NULL);
- pthread_mutex_lock(&mutex);
- PERL_SET_CONTEXT(ctx->ct_perl);
- do_ha_perl(imp_dbh,eventhp,ctx->function);
- pthread_mutex_destroy(&mutex);
-}
-void
-do_ha_perl( imp_dbh_t *imp_dbh, OCIEvent *eventhp,char *function) {
-
- dTHX;
- dSP;
+ ha_ctx_t *ctx =(ha_ctx_t*)ha_ctx;
OCIServer *srvhp;
+ dTHXa(ctx->ctx_perl);
+ dSP;
+ imp_dbh_t *imp_dbh = (imp_dbh_t*)ctx->imp_dbh;
sword status;
text *event_att;
OCIDateTime *event_ts;
@@ -1326,11 +1316,12 @@
ub4 event_code;
HV* ha_event;
AV* servers;
+ PERL_SET_CONTEXT(ctx->ctx_perl);
ha_event = newHV();
servers = newAV();
- PUSHMARK(SP);
+ PUSHMARK(SP);
- PerlIO_printf(DBILOGFP, "DBIc_ACTIVE=%d\n",DBIc_ACTIVE(imp_dbh));
+ PerlIO_printf(DBILOGFP, "DBIc_ACTIVE=%d\n",DBIc_ACTIVE(imp_dbh));
OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_code, 0, OCI_ATTR_HA_SOURCE, imp_dbh->errhp, status);
@@ -1339,10 +1330,8 @@
OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_code, 0, OCI_ATTR_HA_STATUS, imp_dbh->errhp, status);
-
if (event_code == OCI_HA_STATUS_UP){
hv_store(ha_event,"Status",6,sv_2mortal(newSVpv("UP",2)),0);
-
}
else {
hv_store(ha_event,"Status",6,sv_2mortal(newSVpv("DOWN",4)),0);
@@ -1377,7 +1366,7 @@
OCIDateTimeToText(imp_dbh->envhp,imp_dbh->errhp, event_ts, (char*) "MM-DD-YY HH24:MI:SS",
strlen("MM-DD-YY HH24:MI:SS"),
- (ub1)4, (OraText *)0, 0,&event_att_len, tsbuff);
+ 4, (OraText *)0, 0,&event_att_len, tsbuff);
hv_store(ha_event,"Timestamp",9,sv_2mortal(newSVpv((char*)tsbuff,event_att_len)),0);
@@ -1410,44 +1399,37 @@
}
hv_store(ha_event,"Instances",9,newRV_noinc((SV*)servers),0);
- /*sv_2mortal(newRV_inc((SV*)DBIc_MY_H(imp_xxh)))*/
XPUSHs(sv_2mortal(newRV((SV*)DBIc_MY_H(imp_dbh))));
XPUSHs(sv_2mortal(newRV((SV*)ha_event)));
PUTBACK;
- call_pv(function, G_DISCARD);
+ call_pv(ctx->function, G_DISCARD);
}
+/* HA or High Availabilty Callback */
+/* Works like this. The fuction below is registered on the cluster,*/
+/* when a node on a cluster goes up or down then messages are popiegated */
+/* to the other nodes on the cluster. Used for loadbalancing are reconnecting. */
+/* Not very useful to perl as you cannot do much but monitor events as this */
+/* is usisng threaded perl and you go not have a DB handle to play with */
sb4
reg_ha_callback( imp_dbh_t *imp_dbh){
dTHX;
sword status;
- ha_context_t *ctx = NULL;
- /* SV* dbhref = newRV(dbh);
- = sv_setref_iv(dbh, "DBI::db");
- = newSVrv((SV*) dbh, "DBI::db");
-newRV_noinc((SV*) dbh);*/
-/*allocate space for the callback */
- Newz(1, ctx, 1, ha_context_t);
- ctx->function= (char*)safemalloc(strlen(imp_dbh->ha_function));
- ctx->ct_perl = my_perl;
- ctx->imp_dbh = imp_dbh;
- /*sv_setref_pv(dbhref,"DBI::db", dbh);
- ctx->dbh = dbhref; //newSVrv( dbh, "DBI::db");
-sv_bless(dbhref, gv_stashpv("DBI::db", 0));*/
- strcpy((char *)ctx->function,imp_dbh->ha_function);
-
-
-
-PerlIO_printf(DBILOGFP, "reg callback DBIc_ACTIVE=%d\n",DBIc_ACTIVE(imp_dbh));
-
- PerlIO_printf(DBILOGFP, " In reg_ha_callback reg OCI_ATTR_FOCBK =%d, OCI_ATTR_EVTCTX=%d\n",OCI_ATTR_EVTCBK,OCI_ATTR_EVTCTX);
-
- OCIAttrSet_log_stat(imp_dbh->envhp, (ub4) OCI_HTYPE_ENV,(dvoid *)hacb_fn ,(ub4)0,(ub4)OCI_ATTR_EVTCBK, imp_dbh->errhp, status);
+ ha_ctx_t *ctx = NULL;
+ /*allocate space for the callback */
+ Newz(1, ctx, 1, ha_ctx_t);
+ ctx->function = (char*)safemalloc(strlen(imp_dbh->ha_function));
+ ctx->ctx_perl = my_perl;
+ ctx->imp_dbh = imp_dbh;
+
+ if (dbd_verbose >= 5 ) {
+ PerlIO_printf(DBILOGFP, " In reg_ha_callback\n");
+ }
+ OCIAttrSet_log_stat(imp_dbh->envhp, (ub4) OCI_HTYPE_ENV,(dvoid *)ha_cbk ,(ub4)0,(ub4)OCI_ATTR_EVTCBK, imp_dbh->errhp, status);
OCIAttrSet_log_stat(imp_dbh->envhp, OCI_HTYPE_ENV,ctx,0,OCI_ATTR_EVTCTX, imp_dbh->errhp , status);
-PerlIO_printf(DBILOGFP, " In reg_ha_callback reg OCI_ATTR_EVTCX status=%d\n",status);
return status;
}