From 803a944240a83259103f37cd1209865f28698efc Mon Sep 17 00:00:00 2001 From: two56 Date: Thu, 23 Feb 2023 14:13:44 +0000 Subject: [PATCH] Use the request from CallSession for cancel (#268) * Use the req from CallSession for cancel * Check cs is set --------- Co-authored-by: Matt Preskett --- lib/tasks/rest_dial.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/tasks/rest_dial.js b/lib/tasks/rest_dial.js index 926de3d3..cf08801a 100644 --- a/lib/tasks/rest_dial.js +++ b/lib/tasks/rest_dial.js @@ -27,7 +27,7 @@ class TaskRestDial extends Task { */ async exec(cs) { await super.exec(cs); - this.req = cs.req; + this.canCancel = true; this._setCallTimer(); await this.awaitTaskDone(); @@ -36,15 +36,15 @@ class TaskRestDial extends Task { kill(cs) { super.kill(cs); this._clearCallTimer(); - if (this.req) { - this.req.cancel(); - this.req = null; + if (this.canCancel && cs?.req) { + this.canCancel = false; + cs.req.cancel(); } this.notifyTaskDone(); } async _onConnect(dlg) { - this.req = null; + this.canCancel = false; const cs = this.callSession; cs.setDialog(dlg); @@ -79,7 +79,7 @@ class TaskRestDial extends Task { _onCallStatus(status) { this.logger.debug(`CallStatus: ${status}`); if (status >= 200) { - this.req = null; + this.canCancel = false; this._clearCallTimer(); if (status !== 200) this.notifyTaskDone(); }