mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
Fix: Memory leak & connection flood when access /admin/advanced/database
This commit is contained in:
@@ -12,7 +12,17 @@ databaseController.get = function(req, res, next) {
|
|||||||
redis: function(next) {
|
redis: function(next) {
|
||||||
if (nconf.get('redis')) {
|
if (nconf.get('redis')) {
|
||||||
var rdb = require('../../database/redis');
|
var rdb = require('../../database/redis');
|
||||||
var cxn = rdb.connect();
|
// var cxn = rdb.connect();
|
||||||
|
// Do not create new client if it exist.
|
||||||
|
// This will cause memory leak & connection flood
|
||||||
|
var cxn = rdb.client;
|
||||||
|
// Redis was initalized.
|
||||||
|
// Check cxn is unnecessary.
|
||||||
|
// if (!cxn) {
|
||||||
|
// cxn = rdb.client;
|
||||||
|
// rdb.client = cxn;
|
||||||
|
// }
|
||||||
|
|
||||||
rdb.info(cxn, next);
|
rdb.info(cxn, next);
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -111,8 +111,14 @@
|
|||||||
db: db
|
db: db
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// Initial Redis database
|
||||||
|
var rdb = require('./redis');
|
||||||
|
// Create a new redis connection and store it in module (skeleton)
|
||||||
|
rdb.client = rdb.connect();
|
||||||
|
|
||||||
|
//
|
||||||
module.sessionStore = new sessionStore({
|
module.sessionStore = new sessionStore({
|
||||||
client: require('./redis').connect(),
|
client: rdb.client,
|
||||||
ttl: 60 * 60 * 24 * 14
|
ttl: 60 * 60 * 24 * 14
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user