Граф коммитов

28 Коммитов

Автор SHA1 Сообщение Дата
Trevor Norris 75305f3bab events: add check for listeners length
Ability to return just the length of listeners for a given type, using
EventEmitter.listenerCount(emitter, event). This will be a lot cheaper
than creating a copy of the listeners array just to check its length.
2013-03-01 17:36:47 -08:00
isaacs 420e07c577 streams2: The new stream base classes 2012-12-13 17:00:23 -08:00
Soarez 72ce9baa75 streams: remove useless line
The removed line was removing a calllback that was never setup
in first place. 016afe2 forgot to remove this.
2012-10-21 22:58:14 +02:00
koichik 016afe21ae streams: fix pipe is destructed by 'end' from destination 2012-10-03 10:57:31 -07:00
isaacs 41e1b171ec stream.pipe: Don't call destroy() unless it's a function 2012-09-10 16:00:27 -07:00
Maciej Małecki c96df0e37a stream: don't call `cleanup` twice on `end` and `close` 2012-05-28 01:35:36 +02:00
Felix Geisendörfer b3f91f15b2 Remove support for multi-source pipe()
This reverts 6c5b31bd which had too few use cases, too much complexity,
and can be handled in user-land by using `{end: false}`.

Closes #1996
2011-11-22 08:51:19 -08:00
Igor Zinkovsky 13324bf844 throw from stdout.end and stderr.end 2011-11-10 14:51:16 -08:00
Nathan Rajlich 58cb0fa639 Directly export the Stream constructor.
Also setting up a circular reference back to the
stream as `Stream.Stream`, for backwards-compatibility.

Fixes #1933
2011-10-24 15:45:35 -07:00
Ryan Dahl 239b3d62de Remove resume and pause events
Too complex; unnecessary.
2011-10-24 13:23:59 -07:00
Elijah Insua b722aaa8c5 Close #1303 Stream.pipe returns the destination
Squashed:

* Simple change to make Stream.pipe(destination) return the destination Stream
* Test: ensure Stream.pipe(destination) returns the destination Stream
* updated Stream.pipe() documentation to reflect that it now returns the
  destination stream
2011-07-14 14:25:49 -07:00
Felix Geisendörfer 2b91256c61 Fix error handling bug in stream.pipe()
Problem: Since stream.pipe() is registering it's own error handlers on
the source and destination stream, it needs to replicate the
EventEmitter 'error' emitting semantics of throwing an error if there
are no other listeners. However, there was a off-by-one error because
the check for remaining listeners was done after cleanup() which means
the pipe's own listener was no longer included.

This would cause 'error' events on either the dest or the source to
throw if there was one other error listener, and while swallowing
the 'error' event if there was no other listener.

Solution: I added a test demonstrating the two issues and fixed the
problem by correcting the off-by-one error.

Fixes #1095.
2011-05-24 10:50:33 -07:00
Ryan Dahl 75a0cf970f cleartextstream.destroy() should destroy socket.
This fixes a critical bug see in MJR's production. Very difficult to build a
test case. Sometimes HTTPS server gets sockets that are hanging in a
half-duplex state.
2011-05-02 15:03:50 -07:00
isaacs 7c6f0147df Better stream.pipe() tracking.
This commit does three things:

1. Uses an exposed counter rather than a hidden array for tracking dest
streams that may have multiple inputs.  This allows for significantly
faster lookups, since the counter can be checked in constant time rather
than searching an array for the dest object.  (A proper O(1) WeakMap
would be better, but that may have to wait for Harmony.)

2. Calls the 'end' event logic when there is an 'error' event on the
source object (and then throws if there are no other error listeners.)
This is important, because otherwise 'error' events would lead to
memory leaks.

3. Clean up the style a bit.  Function Declarations are not allowed
within blocks in ES strict.  Prefer Function Declarations to Function
Expressions, because hoisting allows for more expressive ordering of
logic.

Downside: It adds "_pipeCount" as part of the Stream API.  It'll work
fine if the member is missing, but if anyone tries to use it for some
other purpose, it can mess things up.
2011-04-27 22:08:21 -07:00
Felix Geisendörfer 6c5b31bd80 Fix: Multiple pipes to the same stream were broken
When creating multiple .pipe()s to the same destination stream, the
first source to end would close the destination, breaking all remaining
pipes. This patch fixes the problem by keeping track of all open
pipes, so that we only call end on destinations that have no more
sources piping to them.

closes #929
2011-04-14 14:12:01 -07:00
Mikeal Rogers 2a65d29625 Fix listener leak in stream.pipe() 2011-03-28 11:19:44 -07:00
Ryan Dahl 55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
Mikeal Rogers 634e7236f7 Add 'pipe' event 2011-02-09 23:04:35 -08:00
Ryan Dahl 8f5f213a6f Revert "Add optional filters to stream.pipe()"
This reverts commit 24aded078f.
2011-01-01 16:41:39 -08:00
Ryan Dahl 24aded078f Add optional filters to stream.pipe() 2010-12-17 13:56:47 -08:00
Ryan Dahl dd53ceebe4 lint 2010-12-01 20:59:06 -08:00
Ryan Dahl e232f6e735 more lint 2010-12-01 20:28:28 -08:00
Ryan Dahl a6f6532dfb Fix test-securepair-server 2010-11-23 18:30:52 -08:00
Ryan Dahl c321e9893d stream.pipe should remove listeners on dest close 2010-11-20 23:08:45 -08:00
Micheil Smith e38eb0c5a4 Soft migration of sys -> util, Removal of deprecated utils module. 2010-10-11 15:21:36 -07:00
Ryan Dahl 81ac0d5088 pipe-test fixes 2010-10-10 22:10:47 -07:00
Ryan Dahl 8ab691726d clean up options.end code - wasn't working 2010-10-10 20:16:21 -07:00
Ryan Dahl bc695475b9 Add Stream base class with stream.pipe 2010-10-10 17:27:03 -07:00