mirror of https://github.com/xwiki-labs/cryptpad
Fix potential memory leak
This commit is contained in:
parent
febafddc2f
commit
5383f9ef1c
|
@ -190,6 +190,9 @@ nThen(function (w) {
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (Env.store) {
|
||||||
|
Env.store.closeInactiveChannels(active);
|
||||||
|
}
|
||||||
if (removed) {
|
if (removed) {
|
||||||
Env.Log.info("CLEANED_ACTIVE_CHANNELS_MAP", {removed});
|
Env.Log.info("CLEANED_ACTIVE_CHANNELS_MAP", {removed});
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,7 @@ const dropChannel = HK.dropChannel = function (Env, chanName) {
|
||||||
expireChannel(Env, chanName);
|
expireChannel(Env, chanName);
|
||||||
}, TEMPORARY_CHANNEL_LIFETIME);
|
}, TEMPORARY_CHANNEL_LIFETIME);
|
||||||
}
|
}
|
||||||
|
store.closeChannel(chanName, function () {});
|
||||||
};
|
};
|
||||||
|
|
||||||
/* checkExpired
|
/* checkExpired
|
||||||
|
|
|
@ -286,6 +286,16 @@ var closeChannel = function (env, channelName, cb) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var closeInactiveChannels = function (env, schedule, active) {
|
||||||
|
Object.keys(env.channels).forEach(channelName => {
|
||||||
|
if (!active.includes(channelName)) {
|
||||||
|
schedule.ordered(channelName, function (next) {
|
||||||
|
closeChannel(env, channelName, next);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var clearOffset = function (env, channelId, cb) {
|
var clearOffset = function (env, channelId, cb) {
|
||||||
var path = mkOffsetPath(env, channelId);
|
var path = mkOffsetPath(env, channelId);
|
||||||
// we should always be able to recover from invalid offsets, so failure to delete them
|
// we should always be able to recover from invalid offsets, so failure to delete them
|
||||||
|
@ -1445,6 +1455,9 @@ module.exports.create = function (conf, _cb) {
|
||||||
closeChannel(env, channelName, Util.both(cb, next));
|
closeChannel(env, channelName, Util.both(cb, next));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
closeInactiveChannels: function (active) {
|
||||||
|
closeInactiveChannels(env, schedule, active);
|
||||||
|
},
|
||||||
// write to a log file
|
// write to a log file
|
||||||
log: function (channelName, content, cb) {
|
log: function (channelName, content, cb) {
|
||||||
// you probably want the events in your log to be in the correct order.
|
// you probably want the events in your log to be in the correct order.
|
||||||
|
|
Loading…
Reference in New Issue