Skip to content

Commit 7c30aaf

Browse files
committed
Make pool.close() the primary release method in the code, not just in the documentation
1 parent 84f796a commit 7c30aaf

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

lib/pool.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
var connection = require('./connection.js');
2323
var nodbUtil = require('./util.js');
2424
var getConnectionPromisified;
25-
var terminatePromisified;
25+
var closePromisified;
2626

2727
// completeConnectionRequest does the actual work of getting a connection from a
2828
// pool when queuing is enabled. It's abstracted out so it can be called from
@@ -206,24 +206,24 @@ function getConnection(getConnectionCb) {
206206

207207
getConnectionPromisified = nodbUtil.promisify(getConnection);
208208

209-
function terminate(terminateCb) {
209+
function close(closeCb) {
210210
var self = this;
211211

212212
nodbUtil.assert(arguments.length === 1, 'NJS-009');
213-
nodbUtil.assert(typeof terminateCb === 'function', 'NJS-006', 1);
213+
nodbUtil.assert(typeof closeCb === 'function', 'NJS-006', 1);
214214

215-
self._terminate(function(err) {
215+
self._close(function(err) {
216216
if (!err) {
217217
self._isValid = false;
218218

219219
self.emit('_after_close', self);
220220
}
221221

222-
terminateCb(err);
222+
closeCb(err);
223223
});
224224
}
225225

226-
terminatePromisified = nodbUtil.promisify(terminate);
226+
closePromisified = nodbUtil.promisify(close);
227227

228228
// logStats is used to add a hidden method (_logStats) to each pool instance. This
229229
// provides an easy way to log out the statistics related information that's collected
@@ -323,7 +323,7 @@ function extend(pool, poolAttrs, poolAlias, oracledb) {
323323
throw new Error(nodbUtil.getErrorMessage('NJS-014', 'queueTimeout'));
324324
}
325325
},
326-
_isValid: { // used to ensure operations are not done after terminate
326+
_isValid: { // used to ensure operations are not done after close
327327
value: true,
328328
writable: true
329329
},
@@ -408,16 +408,16 @@ function extend(pool, poolAttrs, poolAlias, oracledb) {
408408
enumerable: true,
409409
writable: true
410410
},
411-
_terminate: {
412-
value: pool.terminate
411+
_close: {
412+
value: pool.close
413413
},
414-
terminate: {
415-
value: terminatePromisified,
414+
close: {
415+
value: closePromisified,
416416
enumerable: true,
417417
writable: true
418418
},
419-
close: { // alias for terminate
420-
value: terminatePromisified,
419+
terminate: { // alias for close
420+
value: closePromisified,
421421
enumerable: true,
422422
writable: true
423423
}

src/njsPool.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void njsPool::Init(Handle<Object> target)
7777
temp->InstanceTemplate()->SetInternalFieldCount(1);
7878
temp->SetClassName(Nan::New<v8::String>("Pool").ToLocalChecked());
7979

80-
Nan::SetPrototypeMethod(temp, "terminate", Terminate);
80+
Nan::SetPrototypeMethod(temp, "close", Close);
8181
Nan::SetPrototypeMethod(temp, "getConnection", GetConnection);
8282

8383
Nan::SetAccessor(temp->InstanceTemplate(),
@@ -416,15 +416,15 @@ void njsPool::Async_AfterGetConnection(njsBaton *baton, Local<Value> argv[])
416416

417417

418418
//-----------------------------------------------------------------------------
419-
// njsPool::Terminate()
420-
// Terminate the pool. The reference to the DPI handle is transferred to the
419+
// njsPool::Close()
420+
// Close the pool. The reference to the DPI handle is transferred to the
421421
// baton so that it will cleared automatically upon success and so that the
422422
// pool is marked as invalid immediately.
423423
//
424424
// PARAMETERS
425425
// - JS callback which will receive (error)
426426
//-----------------------------------------------------------------------------
427-
NAN_METHOD(njsPool::Terminate)
427+
NAN_METHOD(njsPool::Close)
428428
{
429429
njsBaton *baton;
430430
njsPool *pool;
@@ -437,17 +437,17 @@ NAN_METHOD(njsPool::Terminate)
437437
return;
438438
baton->dpiPoolHandle = pool->dpiPoolHandle;
439439
pool->dpiPoolHandle = NULL;
440-
baton->QueueWork("Terminate", Async_Terminate, NULL, 1);
440+
baton->QueueWork("Close", Async_Close, NULL, 1);
441441
}
442442

443443

444444
//-----------------------------------------------------------------------------
445-
// njsPool::Async_Terminate()
446-
// Worker function for njsPool::Terminate() method. If the attempt to
447-
// terminate the pool fails, the reference to the DPI handle is transferred
448-
// back from the baton to the pool.
445+
// njsPool::Async_Close()
446+
// Worker function for njsPool::Close() method. If the attempt to
447+
// close the pool fails, the reference to the DPI handle is transferred back
448+
// from the baton to the pool.
449449
//-----------------------------------------------------------------------------
450-
void njsPool::Async_Terminate(njsBaton *baton)
450+
void njsPool::Async_Close(njsBaton *baton)
451451
{
452452
if (dpiPool_close(baton->dpiPoolHandle, DPI_MODE_POOL_CLOSE_DEFAULT) < 0) {
453453
njsPool *pool = (njsPool*) baton->callingObj;

src/njsPool.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class njsPool: public njsCommon {
8181
static void Async_GetConnection(njsBaton *baton);
8282
static void Async_AfterGetConnection(njsBaton *baton, Local<Value> argv[]);
8383

84-
// Terminate Methods
85-
static NAN_METHOD(Terminate);
86-
static void Async_Terminate(njsBaton *baton);
84+
// Close Methods
85+
static NAN_METHOD(Close);
86+
static void Async_Close(njsBaton *baton);
8787

8888
// Define Getter Accessors to properties
8989
static NAN_GETTER(GetPoolMax);

0 commit comments

Comments
 (0)