Skip to content

Commit a9017b1

Browse files
committed
Add new pool baton and misc baton updates
1 parent 3ffeaa6 commit a9017b1

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

src/njs/src/njsOracle.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ typedef struct connectionBaton
170170
dpi::Env* dpienv;
171171
dpi::Conn* dpiconn;
172172
dpi::SPool* dpipool;
173-
bool* isPoolValid;
174173

175174
Oracledb *oracledb;
176175

src/njs/src/njsPool.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ Handle<Value> Pool::GetConnection(const Arguments& args)
449449
NJS_GET_CALLBACK ( callback, args );
450450

451451
Pool *njsPool = ObjectWrap::Unwrap<Pool>(args.This());
452-
connectionBaton *connBaton = new connectionBaton ();
452+
poolBaton *connBaton = new poolBaton ();
453453
connBaton->cb = Persistent<Function>::New( callback );
454454

455455
NJS_CHECK_NUMBER_OF_ARGS ( connBaton->error, args, 1, 1, exitGetConnection );
@@ -459,8 +459,7 @@ Handle<Value> Pool::GetConnection(const Arguments& args)
459459
connBaton->error = NJSMessages::getErrorMsg ( errInvalidPool );
460460
goto exitGetConnection;
461461
}
462-
connBaton->dpipool = njsPool->dpipool_;
463-
connBaton->oracledb = njsPool->oracledb_;
462+
connBaton->njspool = njsPool;
464463
connBaton->connClass = njsPool->oracledb_->getConnectionClass ();
465464

466465
exitGetConnection:
@@ -485,13 +484,13 @@ Handle<Value> Pool::GetConnection(const Arguments& args)
485484
*/
486485
void Pool::Async_GetConnection(uv_work_t *req)
487486
{
488-
connectionBaton *connBaton = (connectionBaton *)req->data;
487+
poolBaton *connBaton = (poolBaton *)req->data;
489488
if(!(connBaton->error).empty()) goto exitAsyncGetConnection;
490489

491490
try
492491
{
493-
connBaton->dpiconn = connBaton-> dpipool -> getConnection (
494-
connBaton-> connClass);
492+
connBaton->dpiconn = connBaton-> njspool -> dpipool_ ->
493+
getConnection ( connBaton-> connClass);
495494
}
496495
catch (dpi::Exception &e)
497496
{
@@ -516,7 +515,7 @@ void Pool::Async_GetConnection(uv_work_t *req)
516515
void Pool::Async_AfterGetConnection(uv_work_t *req)
517516
{
518517
HandleScope scope;
519-
connectionBaton *connBaton = (connectionBaton*)req->data;
518+
poolBaton *connBaton = (poolBaton*)req->data;
520519
v8::TryCatch tc;
521520
Handle<Value> argv[2];
522521
if(!(connBaton->error).empty())
@@ -530,8 +529,8 @@ void Pool::Async_AfterGetConnection(uv_work_t *req)
530529
Handle<Object> connection = Connection::connectionTemplate_s->
531530
GetFunction()-> NewInstance();
532531
(ObjectWrap::Unwrap<Connection> (connection))->
533-
setConnection( connBaton->dpiconn,
534-
connBaton->oracledb );
532+
setConnection( connBaton->dpiconn,
533+
connBaton->njspool->oracledb_ );
535534
argv[1] = connection;
536535
}
537536
node::MakeCallback(Context::GetCurrent()->Global(),
@@ -559,7 +558,7 @@ Handle<Value> Pool::Terminate(const Arguments& args )
559558
NJS_GET_CALLBACK ( callback, args );
560559

561560
Pool *njsPool = ObjectWrap::Unwrap<Pool>(args.This());
562-
connectionBaton *terminateBaton = new connectionBaton ();
561+
poolBaton *terminateBaton = new poolBaton ();
563562
terminateBaton->cb = Persistent<Function>::New( callback );
564563

565564
NJS_CHECK_NUMBER_OF_ARGS ( terminateBaton->error, args, 1, 1, exitTerminate );
@@ -569,8 +568,7 @@ Handle<Value> Pool::Terminate(const Arguments& args )
569568
terminateBaton->error = NJSMessages::getErrorMsg( errInvalidPool );
570569
goto exitTerminate;
571570
}
572-
terminateBaton->dpipool = njsPool->dpipool_;
573-
terminateBaton->isPoolValid = &(njsPool->isValid_);
571+
terminateBaton->njspool = njsPool;
574572

575573
exitTerminate:
576574
terminateBaton->req.data = (void *)terminateBaton;
@@ -594,12 +592,12 @@ Handle<Value> Pool::Terminate(const Arguments& args )
594592
*/
595593
void Pool::Async_Terminate(uv_work_t *req)
596594
{
597-
connectionBaton *terminateBaton = (connectionBaton*)req->data;
595+
poolBaton *terminateBaton = (poolBaton*)req->data;
598596
if(!terminateBaton->error.empty()) goto exitAsyncTerminate;
599597

600598
try
601599
{
602-
terminateBaton-> dpipool-> terminate ();
600+
terminateBaton-> njspool-> dpipool_-> terminate ();
603601
}
604602
catch(dpi::Exception& e)
605603
{
@@ -620,7 +618,7 @@ void Pool::Async_Terminate(uv_work_t *req)
620618
void Pool::Async_AfterTerminate(uv_work_t *req)
621619
{
622620
HandleScope scope;
623-
connectionBaton *terminateBaton = (connectionBaton*)req->data;
621+
poolBaton *terminateBaton = (poolBaton*)req->data;
624622

625623
v8::TryCatch tc;
626624

@@ -633,7 +631,8 @@ void Pool::Async_AfterTerminate(uv_work_t *req)
633631
else
634632
{
635633
argv[0] = Undefined();
636-
*(terminateBaton->isPoolValid) = false;
634+
// pool is not valid after terminate succeeds.
635+
terminateBaton-> njspool-> isValid_ = false;
637636
}
638637

639638
node::MakeCallback( Context::GetCurrent()->Global(),

src/njs/src/njsPool.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,25 @@ class Pool: public ObjectWrap {
107107
unsigned int stmtCacheSize_;
108108
};
109109

110+
typedef struct poolBaton
111+
{
112+
uv_work_t req;
113+
std::string error;
114+
std::string connClass;
115+
Persistent<Function> cb;
116+
dpi::Conn* dpiconn;
117+
Pool* njspool;
118+
119+
poolBaton() : error(""), connClass(""),
120+
dpiconn(NULL), njspool(NULL)
121+
{}
122+
123+
~poolBaton()
124+
{
125+
cb.Dispose();
126+
}
127+
128+
}poolBaton;
129+
130+
110131
#endif /* __NJSPOOL_H__ */

0 commit comments

Comments
 (0)