Skip to content
Permalink
Browse files

Fix #107. Stop spamming provisional responses

  • Loading branch information
gavllew authored and jmillan committed Jul 10, 2013
1 parent 7528f90 commit 3fc4efa450eeadeb946a9ae38369bff117575959
Showing with 24 additions and 26 deletions.
  1. +1 −1 package.json
  2. +2 −1 src/Timers.js
  3. +21 −24 src/Transactions.js
@@ -2,7 +2,7 @@
"name": "jssip",
"title": "JsSIP",
"description": "the Javascript SIP library",
"version": "0.3.6",
"version": "0.3.7",
"homepage": "http://jssip.net",
"author": "José Luis Millán <jmillan@aliax.net>",
"contributors": [
@@ -23,7 +23,8 @@ Timers = {
TIMER_J: 0 * T1,
TIMER_K: 0 * T4,
TIMER_L: 64 * T1,
TIMER_M: 64 * T1
TIMER_M: 64 * T1,
PROVISIONAL_RESPONSE_INTERVAL: 60000 // See RFC 3261 Section 13.3.1.1
};

JsSIP.Timers = Timers;
@@ -399,29 +399,20 @@ var InviteServerTransactionPrototype = function() {

console.log(LOG_PREFIX +'transport error occurred, deleting INVITE server transaction ' + this.id);

window.clearTimeout(this.reliableProvisionalTimer);
if (this.resendProvisionalTimer !== null) {
window.clearInterval(this.resendProvisionalTimer);
this.resendProvisionalTimer = null;
}
window.clearTimeout(this.L);
window.clearTimeout(this.H);
window.clearTimeout(this.I);
delete this.ua.transactions.ist[this.id];
}
};

this.timer_reliableProvisional = function(retransmissions) {
var
tr = this,
response = this.last_response,
timeout = JsSIP.Timers.T1 * (Math.pow(2, retransmissions + 1));

if(retransmissions > 8) {
window.clearTimeout(this.reliableProvisionalTimer);
} else {
retransmissions += 1;
if(!this.transport.send(response)) {
this.onTransportError();
}
this.reliableProvisionalTimer = window.setTimeout(function() {
tr.timer_reliableProvisional(retransmissions);}, timeout);
this.resend_provisional = function() {
if(!this.transport.send(this.last_response)) {
this.onTransportError();
}
};

@@ -440,11 +431,11 @@ var InviteServerTransactionPrototype = function() {
}
}

if(status_code > 100 && status_code <= 199) {
// Trigger the reliableProvisionalTimer only for the first non 100 provisional response.
if(!this.reliableProvisionalTimer) {
this.reliableProvisionalTimer = window.setTimeout(function() {
tr.timer_reliableProvisional(1);}, JsSIP.Timers.T1);
if(status_code > 100 && status_code <= 199 && this.state === C.STATUS_PROCEEDING) {
// Trigger the resendProvisionalTimer only for the first non 100 provisional response.
if(this.resendProvisionalTimer === null) {
this.resendProvisionalTimer = window.setInterval(function() {
tr.resend_provisional();}, JsSIP.Timers.PROVISIONAL_RESPONSE_INTERVAL);
}
} else if(status_code >= 200 && status_code <= 299) {
switch(this.state) {
@@ -454,7 +445,10 @@ var InviteServerTransactionPrototype = function() {
this.L = window.setTimeout(function() {
tr.timer_L();
}, JsSIP.Timers.TIMER_L);
window.clearTimeout(this.reliableProvisionalTimer);
if (this.resendProvisionalTimer !== null) {
window.clearInterval(this.resendProvisionalTimer);
this.resendProvisionalTimer = null;
}
/* falls through */
case C.STATUS_ACCEPTED:
// Note that this point will be reached for proceeding tr.state also.
@@ -471,7 +465,10 @@ var InviteServerTransactionPrototype = function() {
} else if(status_code >= 300 && status_code <= 699) {
switch(this.state) {
case C.STATUS_PROCEEDING:
window.clearTimeout(this.reliableProvisionalTimer);
if (this.resendProvisionalTimer !== null) {
window.clearInterval(this.resendProvisionalTimer);
this.resendProvisionalTimer = null;
}
if(!this.transport.send(response)) {
this.onTransportError();
if (onFailure) {
@@ -564,7 +561,7 @@ Transactions.InviteServerTransaction = function(request, ua) {

ua.transactions.ist[this.id] = this;

this.reliableProvisionalTimer = null;
this.resendProvisionalTimer = null;

request.reply(100);
};

10 comments on commit 3fc4efa

@saghul

This comment has been minimized.

Copy link
Contributor

saghul replied Jul 10, 2013

Why did you raise the version in a bugfix patch?!

@jmillan

This comment has been minimized.

Copy link
Member

jmillan replied Jul 10, 2013

In order to avoid an extra commit for each commit in master

@saghul

This comment has been minimized.

Copy link
Contributor

saghul replied Jul 10, 2013

That's terrible. Also, why do we need to bump the version number with every commit?

@jmillan

This comment has been minimized.

Copy link
Member

jmillan replied Jul 10, 2013

This is master. A new commit means a bug has been fixed and goes with the corresponding version increase.

This is defined in the release policy

@saghul

This comment has been minimized.

Copy link
Contributor

saghul replied Jul 10, 2013

I don't think 1 commit == 1 release is defined anywhere. Please bump the version in separated commits, when a release is about to be made.

@ibc

This comment has been minimized.

Copy link
Member

ibc replied Jul 10, 2013

I agree with @saghul. There is no need to make a new release for each fixed bug.

@gavllew

This comment has been minimized.

Copy link
Contributor Author

gavllew replied Jul 10, 2013

It's useful to have some sort of release or stable branch, where a pull will always give you the most up-to-date (and well-tested) release. If master is intended for work-in-progress commits, perhaps an additional branch is needed?

@jmillan

This comment has been minimized.

Copy link
Member

jmillan replied Jul 10, 2013

Hi,

Such branch is develop. It's the next stable branch.

@jmillan

This comment has been minimized.

Copy link
Member

jmillan replied Jul 10, 2013

master branch contains the last stable version plus bugfixes and develop contains the next stable version.

@gavllew

This comment has been minimized.

Copy link
Contributor Author

gavllew replied Jul 10, 2013

But the above discussion suggests that 1 commit != 1 release, which means that the latest master commit may not be a released version. That's why I made the suggestion.

Please sign in to comment.
You can’t perform that action at this time.