mirror of
https://github.com/jambonz/sbc-outbound.git
synced 2026-02-09 02:30:08 +00:00
mem leak fix
This commit is contained in:
@@ -421,12 +421,14 @@ class CallSession extends Emitter {
|
||||
this.uas = uas;
|
||||
this.uac = uac;
|
||||
[uas, uac].forEach((dlg) => {
|
||||
dlg.on('destroy', () => {
|
||||
this.logger.info('call ended');
|
||||
dlg.on('destroy', async() => {
|
||||
const other = dlg.other;
|
||||
this.rtpEngineResource.destroy();
|
||||
this.activeCallIds.delete(this.req.get('Call-ID'));
|
||||
this.unsubscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uac.tag);
|
||||
dlg.other.destroy();
|
||||
try {
|
||||
other.destroy();
|
||||
} catch (err) {}
|
||||
|
||||
this.decrKey(this.callCountKey)
|
||||
.then((count) => {
|
||||
@@ -447,6 +449,14 @@ class CallSession extends Emitter {
|
||||
duration: Math.floor((now - callStart) / 1000)
|
||||
}).catch((err) => this.logger.error({err}, 'Error writing cdr for completed call'));
|
||||
}
|
||||
/* de-link the 2 Dialogs for GC */
|
||||
dlg.removeAllListeners();
|
||||
other.removeAllListeners();
|
||||
dlg.other = null;
|
||||
other.other = null;
|
||||
|
||||
this.logger.info(`call ended with normal termination, there are ${this.activeCallIds.size} active`);
|
||||
|
||||
this.srf.endSession(this.req);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,7 +17,12 @@ module.exports = (srf, logger, opts) => {
|
||||
req.locals = req.locals || {};
|
||||
const callId = req.get('Call-ID');
|
||||
req.locals.account_sid = req.get('X-Account-Sid');
|
||||
req.locals.logger = logger.child({callId, account_sid: req.locals.account_sid});
|
||||
const traceId = req.locals.trace_id = req.get('X-Trace-ID');
|
||||
req.locals.logger = logger.child({
|
||||
callId,
|
||||
traceId,
|
||||
account_sid:
|
||||
req.locals.account_sid});
|
||||
|
||||
if (!req.locals.account_sid) {
|
||||
logger.info('missing X-Account-Sid on outbound call');
|
||||
|
||||
Reference in New Issue
Block a user