@@ -101,16 +101,18 @@ Connection::~Connection()
101
101
Initialize connection attributes after forming it.
102
102
103
103
PARAMETERS:
104
- DPI Connection, Oracledb reference
104
+ DPI Connection, Oracledb reference, reference to js parent
105
105
*/
106
- void Connection::setConnection (dpi::Conn* dpiconn, Oracledb* oracledb)
106
+ void Connection::setConnection (dpi::Conn* dpiconn, Oracledb* oracledb, Local<Object> jsParentObj )
107
107
{
108
108
this ->dpiconn_ = dpiconn;
109
109
this ->isValid_ = true ;
110
110
this ->oracledb_ = oracledb;
111
111
this ->lobCount_ = 0 ;
112
112
this ->rsCount_ = 0 ;
113
113
this ->dbCount_ = 0 ;
114
+
115
+ this ->jsParent_ .Reset ( jsParentObj );
114
116
}
115
117
116
118
/* ****************************************************************************/
@@ -447,7 +449,8 @@ NAN_METHOD(Connection::Execute)
447
449
/* If connection is invalid from JS, then throw an exception */
448
450
NJS_CHECK_OBJECT_VALID2 ( connection, info ) ;
449
451
450
- eBaton *executeBaton = new eBaton ( connection->DBCount (), callback );
452
+ eBaton *executeBaton = new eBaton ( connection->DBCount (), callback,
453
+ info.Holder () );
451
454
452
455
NJS_CHECK_NUMBER_OF_ARGS ( executeBaton->error , info, 2 , 4 , exitExecute );
453
456
@@ -3181,7 +3184,7 @@ v8::Local<v8::Value> Connection::GetOutBindObject ( eBaton *executeBaton )
3181
3184
* Checks whther connection is busy with database call or not using counters
3182
3185
*
3183
3186
* PARAMETERS
3184
- * connection - connection object to check it's counters
3187
+ * connection - connection object to check its counters
3185
3188
*
3186
3189
* Note: Currently this function can be used only in Release () method
3187
3190
*/
@@ -3217,10 +3220,17 @@ NAN_METHOD(Connection::Release)
3217
3220
3218
3221
connection = Nan::ObjectWrap::Unwrap<Connection>(info.Holder ());
3219
3222
3220
- /* If connection is invalide from JS, then throw an exception */
3223
+ /* If connection is invalid from JS, then throw an exception */
3221
3224
NJS_CHECK_OBJECT_VALID2 ( connection, info ) ;
3222
3225
3223
- eBaton *releaseBaton = new eBaton ( connection->DBCount (), callback );
3226
+ eBaton *releaseBaton = new eBaton ( connection->DBCount (), callback,
3227
+ info.Holder () );
3228
+
3229
+ /*
3230
+ * When we release the connection, we have to clear the reference of
3231
+ * its parent.
3232
+ */
3233
+ releaseBaton->njsconn = connection;
3224
3234
3225
3235
NJS_CHECK_NUMBER_OF_ARGS ( releaseBaton->error , info, 1 , 1 , exitRelease );
3226
3236
if (!connection->isValid_ )
@@ -3316,6 +3326,13 @@ void Connection::Async_AfterRelease(uv_work_t *req)
3316
3326
argv[0 ] = v8::Exception::Error (Nan::New<v8::String>((releaseBaton->error ).c_str ()).ToLocalChecked ());
3317
3327
else
3318
3328
argv[0 ] = Nan::Undefined ();
3329
+
3330
+ /*
3331
+ * When we release the connection, we have to clear the reference of
3332
+ * its parent.
3333
+ */
3334
+ releaseBaton->njsconn ->jsParent_ .Reset ();
3335
+
3319
3336
Local<Function> callback = Nan::New<Function>(releaseBaton->cb );
3320
3337
delete releaseBaton;
3321
3338
Nan::MakeCallback ( Nan::GetCurrentContext ()->Global (),
@@ -3346,7 +3363,8 @@ NAN_METHOD(Connection::Commit)
3346
3363
/* if connection is invalid from JS, then throw an exception */
3347
3364
NJS_CHECK_OBJECT_VALID2 ( connection, info ) ;
3348
3365
3349
- eBaton *commitBaton = new eBaton ( connection->DBCount (), callback );
3366
+ eBaton *commitBaton = new eBaton ( connection->DBCount (), callback,
3367
+ info.Holder () );
3350
3368
3351
3369
NJS_CHECK_NUMBER_OF_ARGS ( commitBaton->error , info, 1 , 1 , exitCommit );
3352
3370
if (!connection->isValid_ )
@@ -3452,7 +3470,8 @@ NAN_METHOD(Connection::Rollback)
3452
3470
/* if connection is invalid from JS, then throw an exception */
3453
3471
NJS_CHECK_OBJECT_VALID2 ( connection, info );
3454
3472
3455
- eBaton *rollbackBaton = new eBaton ( connection->DBCount (), callback );
3473
+ eBaton *rollbackBaton = new eBaton ( connection->DBCount (), callback,
3474
+ info.Holder () );
3456
3475
NJS_CHECK_NUMBER_OF_ARGS ( rollbackBaton->error , info, 1 , 1 , exitRollback );
3457
3476
3458
3477
if (!connection->isValid_ )
@@ -3556,7 +3575,8 @@ NAN_METHOD(Connection::Break)
3556
3575
/* If connection is invalid from JS, then throw an exception */
3557
3576
NJS_CHECK_OBJECT_VALID2 ( connection, info );
3558
3577
3559
- eBaton *breakBaton = new eBaton ( connection->DBCount (), callback );
3578
+ eBaton *breakBaton = new eBaton ( connection->DBCount (), callback,
3579
+ info.Holder () );
3560
3580
3561
3581
NJS_CHECK_NUMBER_OF_ARGS ( breakBaton->error , info, 1 , 1 , exitBreak );
3562
3582
0 commit comments