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();

14
package-lock.json generated
View File

@@ -1164,9 +1164,9 @@
"integrity": "sha1-Bmlv43Wvt/68AI8oaCJWukEHWAE="
},
"drachtio-sip": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/drachtio-sip/-/drachtio-sip-0.4.0.tgz",
"integrity": "sha512-/HHK0KH8sfQxUuVrYwaaRxdCq7j6sAQMxzegqzGQeOULx2TNeYb9Bf2SF5AO59DpmYkQRc+ezuHX58EpN/SR7A==",
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/drachtio-sip/-/drachtio-sip-0.4.1.tgz",
"integrity": "sha512-XjrsVb4O5bjgAr/hWogFk8TLoSp2bbOKYhFAFRayiMs/w7PkYep5z5IOW+erbR8LgVDjZVfdGxjA0RPkI4QMvA==",
"requires": {
"debug": "^4.1.1",
"merge": ">=1.2.1",
@@ -1176,16 +1176,16 @@
}
},
"drachtio-srf": {
"version": "4.4.37",
"resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-4.4.37.tgz",
"integrity": "sha512-Z7MpHzee8z6gYVFgLRCqTC2Tt7d0v+EjDLhpZDLpEX0gMTs2Qey+VZ6QxO4CGyMrysZsLBZG5ZBNEifC2gBkHg==",
"version": "4.4.39",
"resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-4.4.39.tgz",
"integrity": "sha512-wqiCe3nM8C9OJwllYVTMoYpVIjtWgX1TcyYy4y0b8jII9uhyB6CaK8aRfgzesZLJ6NTVlioS3a2Ic3e3Cmrkng==",
"requires": {
"async": "^1.4.2",
"debug": "^3.2.6",
"delegates": "^0.1.0",
"deprecate": "^1.1.1",
"drachtio-mw-registration-parser": "0.0.2",
"drachtio-sip": "^0.4.0",
"drachtio-sip": "^0.4.1",
"lodash": "^4.17.20",
"node-noop": "0.0.1",
"only": "0.0.2",

View File

@@ -34,7 +34,7 @@
"debug": "^4.1.1",
"deepcopy": "^2.1.0",
"drachtio-fsmrf": "^2.0.1",
"drachtio-srf": "^4.4.37",
"drachtio-srf": "^4.4.39",
"express": "^4.17.1",
"ip": "^1.1.5",
"jambonz-mw-registrar": "^0.1.3",