Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/protocol/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ var Reader = module.exports = function (Super, args){
return a.block - b.block;
};
this._restransmitterStartFn = function (){
if (me._noMoreData) {
return me._close();
}

var block = me._blockToRetransmit ();
if (block > 0){
//Update the window and emit back to the client the data
Expand Down Expand Up @@ -157,7 +161,9 @@ Reader.prototype._notifyWindow = function (block){

if (this._lastReceived){
this._noMoreData = true;
return this._close ();
// RFC 1350 section 6: On the other hand, delaying is encouraged. This means that the host sending the final
// ACK will wait for a while before terminating in order to retransmit the final ACK if it has been lost
return this.onFinished();
}

this._pending = this._windowSize;
Expand All @@ -168,9 +174,11 @@ Reader.prototype._notifyWindow = function (block){
};

Reader.prototype._onData = function (message){
//DATA packet received after sending the last packet, the socket will be
//closed in the next tick
if (this._noMoreData) return;
//DATA packet received after sending the last packet, the socket is delay-closed so just ACK the client
if (this._noMoreData) {
this._sendAck(message.block);
return;
}

if (message.block === 0 && this._rolloverFix === 0){
//The server has rollovered to 0
Expand Down
3 changes: 3 additions & 0 deletions lib/streams/server/get-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ GetStream.prototype._createReader = function (helper, message, globalOptions){
me.emit ("close");
me.emit ("abort");
};
this._reader.onFinished = function () {
me.push (null); // Closes the stream, but not the Reader
};
this._reader.onClose = function (){
delete me._currFiles.put[me.file];
me.emit ("close");
Expand Down