0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

1476 Commits

Author SHA1 Message Date
Ryan Graham
b02b93b2a2 doc: note a gotcha with http.Server sockets 2013-04-16 23:44:00 +02:00
isaacs
b0de1e4a41 stream: Fix unshift() race conditions
Fix #5272

The consumption of a readable stream is a dance with 3 partners.

1. The specific stream Author (A)
2. The Stream Base class (B), and
3. The Consumer of the stream (C)

When B calls the _read() method that A implements, it sets a 'reading'
flag, so that parallel calls to _read() can be avoided.  When A calls
stream.push(), B knows that it's safe to start calling _read() again.

If the consumer C is some kind of parser that wants in some cases to
pass the source stream off to some other party, but not before "putting
back" some bit of previously consumed data (as in the case of Node's
websocket http upgrade implementation).  So, stream.unshift() will
generally *never* be called by A, but *only* called by C.

Prior to this patch, stream.unshift() *also* unset the state.reading
flag, meaning that C could indicate the end of a read, and B would
dutifully fire off another _read() call to A.  This is inappropriate.
In the case of fs streams, and other variably-laggy streams that don't
tolerate overlapped _read() calls, this causes big problems.

Also, calling stream.shift() after the 'end' event did not raise any
kind of error, but would cause very strange behavior indeed.  Calling it
after the EOF chunk was seen, but before the 'end' event was fired would
also cause weird behavior, and could lead to data being lost, since it
would not emit another 'readable' event.

This change makes it so that:

1. stream.unshift() does *not* set state.reading = false
2. stream.unshift() is allowed up until the 'end' event.
3. unshifting onto a EOF-encountered and zero-length (but not yet
end-emitted) stream will defer the 'end' event until the new data is
consumed.
4. pushing onto a EOF-encountered stream is now an error.

So, if you read(), you have that single tick to safely unshift() data
back into the stream, even if the null chunk was pushed, and the length
was 0.
2013-04-11 16:12:48 -07:00
isaacs
50be39792a blog: Fix title for v0.8.23 release 2013-04-11 11:06:20 -07:00
isaacs
67096fdb38 blog: Post for v0.8.23 2013-04-08 17:41:49 -07:00
Rod Vagg
ccabd4a6fa process: expose NODE_MODULE_VERSION in process.versions 2013-04-08 16:48:18 +02:00
Ben Noordhuis
e8c01739cd doc: document linux pwrite() bug
On Linux, positional writes don't work when the file is opened in
append mode. The kernel ignores the position argument and always
appends the data to the end of the file.

To quote the man page:

  POSIX requires that opening a file with the O_APPEND flag should have
  no affect on the location at which pwrite() writes data.  However, on
  Linux, if a file is opened with O_APPEND, pwrite() appends data to the
  end of the file, regardless of the value of offset.
2013-04-08 00:43:30 +02:00
isaacs
aeef9518c6 doc: Correct caveats for http Readables 2013-04-05 11:07:53 -07:00
isaacs
0f460b03f3 blog: Post about 0.10.3 2013-04-03 11:28:09 -07:00
Michael Hart
440dcae987 Ensure BAD domain example actually uses domain 2013-04-01 10:09:27 -07:00
isaacs
1d17ced200 blog: v0.11.0 release 2013-03-28 14:53:29 -07:00
isaacs
f1fa756681 blog: Update linux binary tarball shasums
I just accidentally the binary release.
2013-03-28 14:39:52 -07:00
isaacs
708e8589ea blog: Post about v0.10.2 2013-03-28 13:06:24 -07:00
isaacs
5ae26f3750 doc: Add 'don't ignore errors' section to domain
Also, an example program of using cluster and domain to handle errors
safely, with zero downtime, using process isolation.
2013-03-28 09:53:59 -07:00
Benjamin Ruston
024a8b0cb4 doc: debugger, dns, http: fix grammar 2013-03-28 16:50:37 +01:00
Benjamin Ruston
372911ffc7 doc: addon: fix grammar 2013-03-27 12:37:54 +01:00
Ben Noordhuis
a80a132b38 doc: child_process: document 'error' event
Fixes #5130.
2013-03-26 16:34:43 +01:00
Ben Noordhuis
0e08e147c7 doc: fix formatting in tty.markdown
Fixes #5135.
2013-03-26 16:09:51 +01:00
Ben Noordhuis
cfd0dca9ae crypto: make getCiphers() return non-SSL ciphers
Commit f53441a added crypto.getCiphers() as a function that returns the
names of SSL ciphers.

Commit 14a6c4e then added crypto.getHashes(), which returns the names of
digest algorithms, but that creates a subtle inconsistency: the return
values of crypto.getHashes() are valid arguments to crypto.createHash()
but that is not true for crypto.getCiphers() - the returned values are
only valid for SSL/TLS functions.

Rectify that by adding tls.getCiphers() and making crypto.getCiphers()
return proper cipher names.
2013-03-25 18:42:07 +01:00
Mathias Bynens
488b74d68b doc: mention process.*.isTTY under process 2013-03-25 13:54:32 +01:00
Ben Noordhuis
132c77e9f9 doc: document that stdio is usually blocking 2013-03-23 15:38:17 +01:00
isaacs
92cc187881 blog: Post for v0.10.1 2013-03-21 09:14:39 -07:00
Iskren Ivov Chernev
2f4a62c5e1 doc: fix streams2 SimpleProtocol example
A non-existing variable `b` was used to queue data for reading.
2013-03-20 00:34:31 +01:00
Ben Noordhuis
808b7ada07 doc: fix broken links in blog footer
The blog lives at blog.nodejs.org while the main website lives at
nodejs.org. Ergo, use absolute URLs for links to the main website.

Fixes #5062.
2013-03-18 14:41:51 +01:00
JeongHoon Byun
f217b5ed62 doc: fix typo in crypto docs 2013-03-17 13:45:14 +01:00
Yi EungJun
852444a720 doc: https: Fix the link to tls.connect 2013-03-16 23:52:39 +01:00
koichik
1f53cfdeae doc: don't mark fs callbacks as optional
Refs #5005, #5008
2013-03-14 13:06:49 -07:00
Adam Malcontenti-Wilson
028c630ecd doc: change dgram to socket for properties of dgram.Socket
Fixes #4919.
2013-03-14 12:55:19 +01:00
Ben Noordhuis
fa05e8a270 doc: implicit fs callbacks don't throw in v0.10
But they will in v0.12.

Re #5005.
2013-03-13 15:34:18 -07:00
Ben Noordhuis
7b7235a232 doc: add note on process.title max length
Fixes #5006.
2013-03-13 23:27:16 +01:00
Ben Noordhuis
9af0085f70 doc: path.join() arguments must be strings
In v0.8, non-string arguments were ignored. v0.10 throws an exception.
2013-03-13 18:42:04 +01:00
isaacs
7a07b31a2f blog: Fix typo in typo fix 2013-03-13 10:15:30 -07:00
Nathan Rajlich
598b5e4593 blog: fix small typo in v0.10.0 release article 2013-03-12 19:00:48 -07:00
Ben Noordhuis
da10bb85ff doc: events: add 'removeListener' event section
Amends commit 84221fd by (also) documenting the 'removeListener' event
in a dedicated section, like the 'newListener' event.

Fixes #4977.
2013-03-12 00:07:18 +01:00
isaacs
228ad9357c blog: Post about v0.10.0 2013-03-11 10:19:19 -07:00
isaacs
061a7ddbff Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	src/node_version.h
2013-03-08 18:59:44 -08:00
isaacs
b3cbb16f41 zlib: Manage flush flags appropriately
If you call z.flush();z.write('foo'); then it would try to write 'foo'
before the flush was done, triggering an assertion in the zlib binding.

Closes #4950
2013-03-08 18:56:31 -08:00
Ben Noordhuis
96a314b68b buffer: strip high bits when converting to ascii
Consider the following example:

  console.log(Buffer('ú').toString('ascii'));

Before this commit, the contents of the buffer was used as-is and hence it
prints 'ú'.

Now, it prints 'C:'. Perhaps not much of an improvement but it conforms to what
the documentation says it does: strip off the high bits.

Fixes #4371.
2013-03-08 14:42:15 -08:00
Andreas Madsen
bdf7ac2c5d child_process: support sending dgram socket
child.send can send net servers and sockets. Now that we have support
for dgram clusters this functionality should be extended to include
dgram sockets.
2013-03-07 17:51:17 +01:00
Ben Noordhuis
71694361f9 doc: dgram: add v0.10 bind() behavior note
dgram.Socket#bind() is always asynchronous now. Add a note at the top
of the documentation that explains how to upgrade.

Fixes #4944.
2013-03-07 14:13:42 +01:00
Ben Noordhuis
924f603e26 doc: dgram: document bind() callback argument 2013-03-07 14:11:46 +01:00
isaacs
9c5812574f blog: Post for v0.8.22 2013-03-06 16:22:23 -08:00
isaacs
f780c6f598 Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	deps/npm/html/api/bin.html
	deps/npm/html/api/bugs.html
	deps/npm/html/api/commands.html
	deps/npm/html/api/config.html
	deps/npm/html/api/deprecate.html
	deps/npm/html/api/docs.html
	deps/npm/html/api/edit.html
	deps/npm/html/api/explore.html
	deps/npm/html/api/help-search.html
	deps/npm/html/api/init.html
	deps/npm/html/api/install.html
	deps/npm/html/api/link.html
	deps/npm/html/api/load.html
	deps/npm/html/api/ls.html
	deps/npm/html/api/npm.html
	deps/npm/html/api/outdated.html
	deps/npm/html/api/owner.html
	deps/npm/html/api/pack.html
	deps/npm/html/api/prefix.html
	deps/npm/html/api/prune.html
	deps/npm/html/api/publish.html
	deps/npm/html/api/rebuild.html
	deps/npm/html/api/restart.html
	deps/npm/html/api/root.html
	deps/npm/html/api/run-script.html
	deps/npm/html/api/search.html
	deps/npm/html/api/shrinkwrap.html
	deps/npm/html/api/start.html
	deps/npm/html/api/stop.html
	deps/npm/html/api/submodule.html
	deps/npm/html/api/tag.html
	deps/npm/html/api/test.html
	deps/npm/html/api/uninstall.html
	deps/npm/html/api/unpublish.html
	deps/npm/html/api/update.html
	deps/npm/html/api/version.html
	deps/npm/html/api/view.html
	deps/npm/html/api/whoami.html
	deps/npm/html/doc/README.html
	deps/npm/html/doc/adduser.html
	deps/npm/html/doc/bin.html
	deps/npm/html/doc/bugs.html
	deps/npm/html/doc/build.html
	deps/npm/html/doc/bundle.html
	deps/npm/html/doc/cache.html
	deps/npm/html/doc/changelog.html
	deps/npm/html/doc/coding-style.html
	deps/npm/html/doc/completion.html
	deps/npm/html/doc/config.html
	deps/npm/html/doc/dedupe.html
	deps/npm/html/doc/deprecate.html
	deps/npm/html/doc/developers.html
	deps/npm/html/doc/disputes.html
	deps/npm/html/doc/docs.html
	deps/npm/html/doc/edit.html
	deps/npm/html/doc/explore.html
	deps/npm/html/doc/faq.html
	deps/npm/html/doc/folders.html
	deps/npm/html/doc/global.html
	deps/npm/html/doc/help-search.html
	deps/npm/html/doc/help.html
	deps/npm/html/doc/index.html
	deps/npm/html/doc/init.html
	deps/npm/html/doc/install.html
	deps/npm/html/doc/json.html
	deps/npm/html/doc/link.html
	deps/npm/html/doc/ls.html
	deps/npm/html/doc/npm.html
	deps/npm/html/doc/outdated.html
	deps/npm/html/doc/owner.html
	deps/npm/html/doc/pack.html
	deps/npm/html/doc/prefix.html
	deps/npm/html/doc/prune.html
	deps/npm/html/doc/publish.html
	deps/npm/html/doc/rebuild.html
	deps/npm/html/doc/registry.html
	deps/npm/html/doc/removing-npm.html
	deps/npm/html/doc/restart.html
	deps/npm/html/doc/rm.html
	deps/npm/html/doc/root.html
	deps/npm/html/doc/run-script.html
	deps/npm/html/doc/scripts.html
	deps/npm/html/doc/search.html
	deps/npm/html/doc/semver.html
	deps/npm/html/doc/shrinkwrap.html
	deps/npm/html/doc/star.html
	deps/npm/html/doc/stars.html
	deps/npm/html/doc/start.html
	deps/npm/html/doc/stop.html
	deps/npm/html/doc/submodule.html
	deps/npm/html/doc/tag.html
	deps/npm/html/doc/test.html
	deps/npm/html/doc/uninstall.html
	deps/npm/html/doc/unpublish.html
	deps/npm/html/doc/update.html
	deps/npm/html/doc/version.html
	deps/npm/html/doc/view.html
	deps/npm/html/doc/whoami.html
	deps/npm/man/man1/ls.1
	deps/npm/man/man1/npm.1
	deps/npm/man/man3/npm.3
	deps/npm/node_modules/npm-registry-client/lib/publish.js
	deps/npm/node_modules/npm-registry-client/package.json
	deps/npm/package.json
	doc/blog/feature/streams2.md
2013-03-06 15:43:02 -08:00
isaacs
277a2545d2 blog: Update streams2 feature post to match actual doc 2013-03-06 14:19:16 -08:00
isaacs
116d6c4402 blog: Post for 0.9.12 2013-03-06 13:57:57 -08:00
isaacs
d258fb0212 http: More useful setTimeout API on server
This adds the following to HTTP:

* server.setTimeout(msecs, callback)
  Sets all new connections to time out after the specified time, at
  which point it emits 'timeout' on the server, passing the socket as an
  argument.
  In this way, timeouts can be handled in one place consistently.
* req.setTimeout(), res.setTimeout()
  Essentially an alias to req/res.socket.setTimeout(), but without
  having to delve into a "buried" object.  Adds a listener on the
  req/res object, but not on the socket.
* server.timeout
  Number of milliseconds before incoming connections time out.
  (Default=1000*60*2, as before.)

Furthermore, if the user sets up their own timeout listener on either
the server, the request, or the response, then the default behavior
(destroying the socket) is suppressed.

Fix #3460
2013-03-06 12:43:48 -08:00
isaacs
b0f6789a78 stream: Remove bufferSize option
Now that highWaterMark increases when there are large reads, this
greatly reduces the number of calls necessary to _read(size), assuming
that _read actually respects the size argument.
2013-03-06 11:44:30 -08:00
isaacs
5038f40185 node: Add --throw-deprecation
Extremely handy when tracking down a flood of recursive nextTick warnings.
2013-03-06 11:44:29 -08:00
isaacs
426b4c6258 stream: _write takes an encoding argument
This vastly reduces the overhead of decodeStrings:false streams,
such as net and http.
2013-03-05 14:27:15 -08:00
isaacs
cd68d86c32 stream: Remove output function from _transform
Just use stream.push(outputChunk) instead.
2013-03-05 14:27:15 -08:00
Paolo Fragomeni
8e2376b376 Update domain.markdown 2013-03-05 08:15:54 -08:00