不要怂,就是干,撸起袖子干!

Commit 7b73f271 by Andy Burke

Fix an issue with checking if we still need a connection.

Conflicts:

	lib/dialects/mysql/connector-manager.js
1 parent cd57fd14
Showing with 8 additions and 3 deletions
......@@ -89,7 +89,7 @@ module.exports = (function() {
var cleanup = function () {
var retryCt = 0
// make sure to let client finish before calling destroy
if (self && !self.hasNoConnections) {
if (self && self.hasQueuedItems) {
return
}
// needed to prevent mysql connection leak
......@@ -184,8 +184,13 @@ module.exports = (function() {
queueItem.query.run(queueItem.sql, queueItem.client)
}
ConnectorManager.prototype.__defineGetter__('hasQueuedItems', function() {
return (this.queue.length > 0) || (this.activeQueue.length > 0) || (this.client._queue && (this.client._queue.length > 0))
})
// legacy
ConnectorManager.prototype.__defineGetter__('hasNoConnections', function() {
return (this.queue.length == 0) && (this.activeQueue.length == 0) && (this.client == null || (this.client._queue && (this.client._queue.length == 0)))
return !this.hasQueuedItems
})
ConnectorManager.prototype.__defineGetter__('isConnected', function() {
......@@ -197,7 +202,7 @@ module.exports = (function() {
this.disconnectTimeoutId && clearTimeout(this.disconnectTimeoutId)
this.disconnectTimeoutId = setTimeout(function() {
self.isConnected && self.hasNoConnections && self.disconnect()
self.isConnected && !self.hasQueuedItems && self.disconnect()
}, 100)
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!