fix two B2B race conditions: overlapping requests to freeswitch, and simultaneous answer on B with Cancel on A

This commit is contained in:
Dave Horton
2020-10-20 11:56:09 -04:00
parent 950f1c83b7
commit fff52c930c
3 changed files with 14 additions and 14 deletions

View File

@@ -108,11 +108,11 @@ class SingleDialer extends Emitter {
this.ep = await ms.createEndpoint();
this.logger.debug(`SingleDialer:exec - created endpoint ${this.ep.uuid}`);
let promiseStreamConnected;
let lastSdp;
const connectStream = async(remoteSdp) => {
// wait for previous re-invite to complete, if any
if (promiseStreamConnected) await promiseStreamConnected.catch((err) => {});
return promiseStreamConnected = this.ep.modify(remoteSdp);
if (remoteSdp === lastSdp) return;
lastSdp = remoteSdp;
return this.ep.modify(remoteSdp);
};
Object.assign(opts, {
@@ -161,9 +161,9 @@ class SingleDialer extends Emitter {
this.emit('callStatusChange', status);
}
});
await connectStream(this.dlg.remote.sdp);
this.dlg.callSid = this.callSid;
this.inviteInProgress = null;
this.dlg.callSid = this.callSid;
await connectStream(this.dlg.remote.sdp);
this.emit('callStatusChange', {sipStatus: 200, callStatus: CallStatus.InProgress});
this.logger.debug(`SingleDialer:exec call connected: ${this.callSid}`);
const connectTime = this.dlg.connectTime = moment();