mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-22 01:27:55 +00:00
fix two B2B race conditions: overlapping requests to freeswitch, and simultaneous answer on B with Cancel on A
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user