Commit f2467ce5 authored by deuce's avatar deuce
Browse files

Fixes for v1.0 mode...

1) Don't reset eob counts for sent or got.
2) Ensure M_GET is never sent in v1.0 mode.
3) Only send one M_EOB in v1.0 mode, even if we add to the list with M_GET

This should cover all the bases, but FREQ may be non-conformant.
parent 9ae308d1
......@@ -228,6 +228,10 @@ BinkP.prototype.crypt = {
return ret;
},
};
BinkP.prototype.reset_eob = function() {
if (this.ver1_1)
this.senteob = this.goteob = 0;
};
BinkP.prototype.send_chunks = function(str) {
var ret;
var sent = 0;
......@@ -711,14 +715,16 @@ BinkP.prototype.session = function()
this.ack_file();
if (this.pending_ack.length > 0)
log(LOG_WARNING, "We got an M_EOB, but there are still "+this.pending_ack.length+" files pending M_GOT");
else {
if (this.ver1_1) {
if (this.senteob >= 2 && this.goteob >= 2)
break outer;
}
else {
if (this.senteob > 0)
if (this.senteob > 0 && this.goteob > 0)
break outer;
}
}
break;
case this.command.M_GOT:
args = this.parseArgs(pkt.data);
......@@ -812,8 +818,13 @@ BinkP.prototype.session = function()
if (this.sending === undefined) {
this.sending = this.tx_queue.shift();
if (this.sending === undefined) {
if (this.ver1_1)
this.sendCmd(this.command.M_EOB);
else {
if (!this.senteob)
this.sendCmd(this.command.M_EOB);
}
}
else {
this.pending_ack.push(this.sending);
log(LOG_INFO, "Sending file: " + this.sending.file.name + format(" (%1.1fKB)", this.sending.file.length / 1024.0));
......@@ -828,6 +839,7 @@ BinkP.prototype.session = function()
}
}
if (this.sending !== undefined) {
if (this.ver1_1 || this.senteob === 0) {
if (this.sending.waitingForGet !== undefined && !this.sending.waitingForGet) {
if(this.sendData(this.sending.file.read(32767)))
last = Date.now();
......@@ -838,6 +850,7 @@ BinkP.prototype.session = function()
}
}
}
}
if ((last + this.timeout)*1000 < Date.now())
this.sendCmd(this.command.M_ERR, "Timeout exceeded!");
......@@ -917,7 +930,7 @@ BinkP.prototype.sendCmd = function(cmd, data)
}
break;
default:
this.senteob=this.goteob=0;
this.reset_eob();
}
return true;
};
......@@ -1051,7 +1064,7 @@ BinkP.prototype.recvFrame = function(timeout)
if (nullpos > -1)
ret.data = ret.data.substr(0, nullpos);
if (ret.command != this.command.M_EOB)
this.goteob = this.senteob = 0;
this.reset_eob();
switch(ret.command) {
case this.command.M_ERR:
log(LOG_ERROR, "BinkP got fatal error from remote: '"+ret.data+"'.");
......@@ -1159,7 +1172,7 @@ BinkP.prototype.recvFrame = function(timeout)
}
}
else
this.goteob = this.senteob = 0;
this.reset_eob();
}
return ret;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment