Revision c024d2d8 lib/_stream_readable.js

View differences:

lib/_stream_readable.js
400 400

  
401 401
  function cleanup() {
402 402
    // cleanup event handlers once the pipe is broken
403
    dest.removeListener('close', unpipe);
403
    dest.removeListener('close', onclose);
404 404
    dest.removeListener('finish', onfinish);
405 405
    dest.removeListener('drain', ondrain);
406 406
    dest.removeListener('error', onerror);
......
426 426
  }
427 427
  dest.once('error', onerror);
428 428

  
429
  // if the dest emits close, then presumably there's no point writing
430
  // to it any more.
431
  dest.once('close', unpipe);
429
  // Both close and finish should trigger unpipe, but only once.
430
  function onclose() {
431
    dest.removeListener('finish', onfinish);
432
    unpipe();
433
  }
434
  dest.once('close', onclose);
432 435
  function onfinish() {
433
    dest.removeListener('close', unpipe);
436
    dest.removeListener('close', onclose);
437
    unpipe();
434 438
  }
435 439
  dest.once('finish', onfinish);
436 440

  

Also available in: Unified diff