spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

WINDOW_UPDATE frames should be sent even when windowSize is positive #144

Closed clowwindy closed 10 years ago

clowwindy commented 10 years ago

According to SPDY Protocol - Draft 3.1

The receiver of a frame sends a WINDOW_UPDATE frame as it consumes data and frees up space in flow control windows. Separate WINDOW_UPDATE frames are sent for the stream and connection level flow control windows.

But node-spdy only sends WINDOW_UPDATE frames when window size is 0. Therefore when window size reduces to 0, the connection gets stuck until the sender receives a new WINDOW_UPDATE frame. Therefore, there is a duration of RTT(round trip time) during which the connection completely gets stuck.

// connection.js

// ### function sendWindowUpdate (force)
// #### @force {Boolean} send even if windowSize is positive
// Send WINDOW_UPDATE if needed
//
Connection.prototype._sendWindowUpdate = function sendWindowUpdate(force) {
  var state = this._spdyState;

  if (state.version < 3.1 && (!state.isServer || !state.autoSpdy31) ||
      state.windowSize > 0 && !force) {
    return;
  }
  // ...
}