@@ -101,16 +101,18 @@ Connection::~Connection()
101101 Initialize connection attributes after forming it.
102102
103103 PARAMETERS:
104- DPI Connection, Oracledb reference
104+ DPI Connection, Oracledb reference, reference to js parent
105105*/
106- void Connection::setConnection (dpi::Conn* dpiconn, Oracledb* oracledb)
106+ void Connection::setConnection (dpi::Conn* dpiconn, Oracledb* oracledb, Local<Object> jsParentObj )
107107{
108108 this ->dpiconn_ = dpiconn;
109109 this ->isValid_ = true ;
110110 this ->oracledb_ = oracledb;
111111 this ->lobCount_ = 0 ;
112112 this ->rsCount_ = 0 ;
113113 this ->dbCount_ = 0 ;
114+
115+ this ->jsParent_ .Reset ( jsParentObj );
114116}
115117
116118/* ****************************************************************************/
@@ -447,7 +449,8 @@ NAN_METHOD(Connection::Execute)
447449 /* If connection is invalid from JS, then throw an exception */
448450 NJS_CHECK_OBJECT_VALID2 ( connection, info ) ;
449451
450- eBaton *executeBaton = new eBaton ( connection->DBCount (), callback );
452+ eBaton *executeBaton = new eBaton ( connection->DBCount (), callback,
453+ info.Holder () );
451454
452455 NJS_CHECK_NUMBER_OF_ARGS ( executeBaton->error , info, 2 , 4 , exitExecute );
453456
@@ -3181,7 +3184,7 @@ v8::Local<v8::Value> Connection::GetOutBindObject ( eBaton *executeBaton )
31813184 * Checks whther connection is busy with database call or not using counters
31823185 *
31833186 * PARAMETERS
3184- * connection - connection object to check it's counters
3187+ * connection - connection object to check its counters
31853188 *
31863189 * Note: Currently this function can be used only in Release () method
31873190 */
@@ -3217,10 +3220,17 @@ NAN_METHOD(Connection::Release)
32173220
32183221 connection = Nan::ObjectWrap::Unwrap<Connection>(info.Holder ());
32193222
3220- /* If connection is invalide from JS, then throw an exception */
3223+ /* If connection is invalid from JS, then throw an exception */
32213224 NJS_CHECK_OBJECT_VALID2 ( connection, info ) ;
32223225
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;
32243234
32253235 NJS_CHECK_NUMBER_OF_ARGS ( releaseBaton->error , info, 1 , 1 , exitRelease );
32263236 if (!connection->isValid_ )
@@ -3316,6 +3326,13 @@ void Connection::Async_AfterRelease(uv_work_t *req)
33163326 argv[0 ] = v8::Exception::Error (Nan::New<v8::String>((releaseBaton->error ).c_str ()).ToLocalChecked ());
33173327 else
33183328 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+
33193336 Local<Function> callback = Nan::New<Function>(releaseBaton->cb );
33203337 delete releaseBaton;
33213338 Nan::MakeCallback ( Nan::GetCurrentContext ()->Global (),
@@ -3346,7 +3363,8 @@ NAN_METHOD(Connection::Commit)
33463363 /* if connection is invalid from JS, then throw an exception */
33473364 NJS_CHECK_OBJECT_VALID2 ( connection, info ) ;
33483365
3349- eBaton *commitBaton = new eBaton ( connection->DBCount (), callback );
3366+ eBaton *commitBaton = new eBaton ( connection->DBCount (), callback,
3367+ info.Holder () );
33503368
33513369 NJS_CHECK_NUMBER_OF_ARGS ( commitBaton->error , info, 1 , 1 , exitCommit );
33523370 if (!connection->isValid_ )
@@ -3452,7 +3470,8 @@ NAN_METHOD(Connection::Rollback)
34523470 /* if connection is invalid from JS, then throw an exception */
34533471 NJS_CHECK_OBJECT_VALID2 ( connection, info );
34543472
3455- eBaton *rollbackBaton = new eBaton ( connection->DBCount (), callback );
3473+ eBaton *rollbackBaton = new eBaton ( connection->DBCount (), callback,
3474+ info.Holder () );
34563475 NJS_CHECK_NUMBER_OF_ARGS ( rollbackBaton->error , info, 1 , 1 , exitRollback );
34573476
34583477 if (!connection->isValid_ )
@@ -3556,7 +3575,8 @@ NAN_METHOD(Connection::Break)
35563575 /* If connection is invalid from JS, then throw an exception */
35573576 NJS_CHECK_OBJECT_VALID2 ( connection, info );
35583577
3559- eBaton *breakBaton = new eBaton ( connection->DBCount (), callback );
3578+ eBaton *breakBaton = new eBaton ( connection->DBCount (), callback,
3579+ info.Holder () );
35603580
35613581 NJS_CHECK_NUMBER_OF_ARGS ( breakBaton->error , info, 1 , 1 , exitBreak );
35623582
0 commit comments