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

456 Commits

Author SHA1 Message Date
isaacs
77ed12fe7a Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/test/test-spawn.c
	deps/uv/uv.gyp
	src/cares_wrap.cc
	src/node.cc
	src/node_version.h
	test/simple/test-buffer.js
	tools/gyp/pylib/gyp/common.py
	tools/install.py
2012-12-13 16:57:58 -08:00
Joshua Erickson
c9f2531ae0 net: More accurate IP address validation and IPv6 dotted notation.
* Added isIP method to make use of inet_pton to cares_wrap.cc
* Modified net.isIP() to make use of new C++ isIP method.
* Added new tests to test-net-isip.js.

This is a back-port of commit fb6377e from the master branch.
2012-11-28 21:51:27 +01:00
Ben Noordhuis
4cb17cb219 net: fix net.connect() resource leak
The 'connect' event listener was attached with .on(), which blocked it from
getting garbage collected. Use .once() instead.

Fixes #4308.
2012-11-24 15:27:14 +01:00
Scott Blomquist
f657ce685d windows: add tracing with performance counters
Patch by Henry Rawas and Scott Blomquist.
2012-11-21 01:21:53 +01:00
Joshua Erickson
fb6377ebd0 net: More accurate IP address validation and IPv6 dotted notation.
* Added isIP method to make use of inet_pton to cares_wrap.cc
* Modified net.isIP() to make use of new C++ isIP method.
* Added new tests to test-net-isip.js.
2012-11-06 16:49:21 +01:00
isaacs
061f2075cf string_decoder: Add 'end' method, do base64 properly 2012-10-11 16:46:18 -07:00
Ben Noordhuis
972cdf82f1 Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	deps/uv/include/uv.h
	src/node_crypto.cc
2012-09-04 15:02:20 +02:00
Shigeki Ohtsu
f347077e78 tls: support unix domain socket/named pipe in tls.connect 2012-08-31 00:23:36 +02:00
Bert Belder
bf16d9280e Merge branch 'v0.8'
Conflicts:
	ChangeLog
	deps/openssl/openssl.gyp
	src/node_version.h
2012-08-28 02:54:22 +02:00
Ben Noordhuis
422772f23b net: fix asserts
Fixes a 'Converting circular structure to JSON' TypeError.
2012-08-23 16:03:48 +02:00
Ben Noordhuis
a177f55b0c Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	ChangeLog
	src/node_version.h
	test/message/stdin_messages.out
	tools/install.py
2012-08-17 13:05:20 +02:00
Ben Noordhuis
4c150ca0d0 net: fix listen() regression, revert patches
This commit reverts the following commits (in reverse chronological order):

  74d076c errnoException must be done immediately
  ddb02b9 net: support Server.listen(Pipe)
  085a098 cluster: do not use internal server API
  d138875 net: lazy listen on handler

Commit d138875 introduced a backwards incompatible change that broke the
simple/test-net-socket-timeout and simple/test-net-lazy-listen tests - it
defers listening on the target port until the `net.Server` instance has at
least one 'connection' event listener.

The other patches had to be reverted in order to revert d138875.

Fixes #3832.
2012-08-06 23:55:38 +02:00
Josh Erickson
7b367a93ce net: add support for IPv6 addresses ending in ::
Modified net.isIP Ipv6 regex to allow for addresses ending in "::".
Added tests for new IPv6 matching reqex.
2012-08-06 22:25:55 +02:00
isaacs
7bb814f9db errnoException must be done immediately 2012-08-05 14:42:22 -07:00
isaacs
74d076caf1 errnoException must be done immediately 2012-08-05 14:22:44 -07:00
Andreas Madsen
ddb02b978d net: support Server.listen(Pipe) 2012-08-05 13:53:31 -07:00
Andreas Madsen
085a09874b cluster: do not use internal server API 2012-08-05 13:53:31 -07:00
Andreas Madsen
d13887512e net: lazy listen on handler
This allow the server to be shared without the need to handle connection
from master
2012-08-04 22:13:07 -07:00
isaacs
3bf1846bb7 Merge remote-tracking branch 'ry/v0.8'
Conflicts:
	ChangeLog
	deps/uv/src/unix/sunos.c
	deps/uv/test/test-tcp-unexpected-read.c
	src/node_version.h
2012-08-03 16:23:14 -07:00
Bert Belder
5fdeebd94d net: make pause work with connecting sockets
This fixes the problem that calling pause() on a socket would not
actually prevent 'data' events from being emitted. It also replaces
the existing test by a more elaborate one.

Ref: #3118
2012-08-03 17:11:08 +02:00
Ben Noordhuis
34c750d7a9 net: fix .listen({fd:0}) 2012-08-02 13:37:02 +02:00
Ben Noordhuis
aa0650f444 cluster: fix libuv assert in net.listen()
Problem: calling `server.listen()` (no port) on a net.Server triggered the
following libuv assertion:

  node: ../deps/uv/src/unix/stream.c:406: uv__write: Assertion `fd_to_send >= 0'
  failed.

Cause: uv_tcp_t handles are lazily initialized. Omitting the port made the
handle get initialized even more lazily. Too lazily - it wasn't initialized
when the handle was sent over to the child process.

Solution: implicitly bind to a random port in listen() when the port number
is omitted, it forces the handle to initialize. This is not a change in
behavior, listen() has always been identical to listen(0).

Fixes #3325.
2012-07-29 02:07:16 +02:00
isaacs
e5498331f4 Merge remote-tracking branch 'ry/v0.8'
Conflicts:
	AUTHORS
	ChangeLog
	src/node_version.h
2012-07-26 11:58:03 -07:00
isaacs
5809426d75 net.js: lint 2012-07-24 17:05:31 -07:00
Ben Noordhuis
1513848f88 net: fix Socket({ fd: 42 }) api
Make the implementation match the documentation. This should work:

  var s = new net.Socket({ fd: 42, allowHalfOpen: true };

And now it does.
2012-07-24 15:53:22 -07:00
Timothy J Fontaine
2637b5c261 ref/unref for net.Socket net.Server dgram.Socket 2012-07-23 18:31:30 +02:00
Fedor Indutny
1fa0bca2ad net: ignore socket.setTimeout(Infinity) (and NaN) 2012-07-20 01:49:30 +04:00
Fedor Indutny
b0950cbea2 net: ignore socket.setTimeout(Infinity) (and NaN) 2012-07-20 00:43:41 +04:00
Ben Noordhuis
3a6314dbe1 net: fix net.Server.listen({fd:x}) error reporting
* don't assert when fd isn't an open file descriptor

* don't die with a ReferenceError when fd isn't a file descriptor
  you can listen() on

Fixes #3699.
2012-07-12 18:18:38 +02:00
Ben Noordhuis
5d97d72753 net: fix bogus errno reporting
_listen2() emits the error on the next tick. The errno value may have changed
by then.
2012-07-12 16:56:44 +02:00
Jonas Westerlund
e5bb8391a8 Do not assign to properties that only have getters
It is an error in strict mode, and silent failure otherwise.
2012-07-06 19:28:35 -07:00
isaacs
5b39929d47 Add --no-deprecation and --trace-deprecation flags 2012-06-21 12:05:33 -07:00
isaacs
1df222f179 Fix breakage introduced in de65ba7 2012-06-18 16:04:36 -07:00
isaacs
de65ba7aba net.Socket: Delay pause/resume until after connect
Fix #3118
2012-06-18 15:17:20 -07:00
Reid Burke
71a2a2caa6 net: Prevent property access throws during close
Fix #3455.

The remoteAddress and remotePort properties are
dynamically retrieved from _getpeername().

While _getpeername() checks if the _handle is
null, it is also possible for the tcp_wrapped
_handle.getpeername() to return null on error.

Such a condition happens when the remote closes
and one of these properties is accessed before
_handle is set to null.
2012-06-17 13:00:00 -07:00
isaacs
41421ff9da Make listenFD just DTRT after warning 2012-06-16 16:26:16 -07:00
Andreas Madsen
1e0ce5d1bd domain: the EventEmitter constructor is now always called in nodecore 2012-06-15 09:49:05 -07:00
isaacs
e733dc3bc3 Fix #3388 Support listening on file descriptors
This implements server.listen({ fd: <filedescriptor> }).  The fd should
refer to an underlying resource that is already bound and listening, and
causes the new server to also accept connections on it.

Not supported on Windows.  Raises ENOTSUP.
2012-06-13 12:24:45 -07:00
Ben Noordhuis
f0a561fe67 net: rename flag FLAG_SHUTDOWNQUED 2012-06-04 15:02:09 +02:00
Ben Noordhuis
fa9aa1c961 net: fix 'close' event emit order
The server 'close' event was emitted before the last client 'close' event. Not
exactly fatal but potentially confusing.

Before this commit the order looked something like [client, server, client],
now it looks like [client, client, server].

See #3340 for more details.
2012-05-29 13:05:51 +02:00
Ben Noordhuis
039fac633e deps: upgrade libuv to a478847
The event loop's reference counting scheme in this version of libuv has changed.
Update the libuv bindings to reflect that fact.
2012-05-22 16:14:24 +02:00
Andreas Madsen
81a4edcf6a cluster: remove NODE_UNIQUE_ID from env on startup
In case a worker would spawn a new subprocess with process.env, NODE_UNIQUE_ID
would have been a part of the env. Making the new subprocess believe it is a
worker, this would result in some confusion if the subprocess where to listen to
a port, since the server handle request would then be relayed to the worker.

This patch removes the NODE_UNIQUE_ID flag from process.env on startup so any
subprocess spawned by a worker is a normal process with no cluster stuff.
2012-05-21 23:27:44 +02:00
Ben Noordhuis
f66f793c07 net: hook up handle wrap to owning object 2012-05-15 16:59:00 +02:00
Andreas Madsen
dceebbfa31 child_process: allow sending a net Socket and Server object using child.send
child_process.fork() support sending native hander object, this patch add support for sending
net.Server and net.Socket object by converting the object to a native handle object and back
to a useful object again.

Note when sending a Socket there was emitted by a net Server object, the server.connections
property becomes null, because it is no longer possible to known when it is destroyed.
2012-05-14 07:47:52 -07:00
rsolomo
d40415912f net: make isIP() return 0 on empty input 2012-05-14 16:09:04 +02:00
Bert Belder
27ddd14e9f net.js: make Socket.bytesWritten work again
Earlier string write optimizations broke it.
2012-05-09 04:00:07 +02:00
Bert Belder
0e57aafbb1 Optimize writing strings with Socket.write 2012-05-09 03:56:19 +02:00
Bert Belder
bb675baaa9 net.js: don't pretend that everything is okay when unwrapping fails
In case of an UNWRAP failure, the binding returns -1, which is truthy.
2012-05-09 03:56:06 +02:00
Brian Schroeder
436a9b69f3 net: signal localAddress bind failure in connect 2012-05-05 01:30:32 +02:00
Erik Dubbelboer
3d69bbfa87 net, http: add backlog parameter to .listen() 2012-04-18 21:40:25 +02:00
isaacs
33c76f19de net.js: lint 2012-04-18 12:24:41 -07:00
isaacs
ecca7525cc Merge remote-tracking branch 'ry/v0.6' into master
Conflicts:
	AUTHORS
	ChangeLog
	LICENSE
	Makefile
	deps/http_parser/test.c
	deps/npm/AUTHORS
	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/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/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/list.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/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/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/lib/npm.js
	deps/npm/man/man1/npm.1
	deps/npm/man/man3/npm.3
	deps/npm/node_modules/fstream-npm/fstream-npm.js
	deps/npm/node_modules/fstream-npm/node_modules/fstream-ignore/package.json
	deps/npm/node_modules/fstream-npm/package.json
	deps/npm/node_modules/node-gyp/LICENSE
	deps/npm/node_modules/node-gyp/lib/build.js
	deps/npm/node_modules/node-gyp/lib/install.js
	deps/npm/node_modules/node-gyp/node_modules/ansi/package.json
	deps/npm/node_modules/node-gyp/node_modules/glob/package.json
	deps/npm/node_modules/node-gyp/package.json
	deps/npm/package.json
	deps/uv/test/test-fs.c
	deps/v8/src/regexp-macro-assembler-tracer.cc
	deps/v8/src/version.cc
	src/node_version.h
	src/platform_sunos.cc
	test/simple/test-net-write-after-close.js
	wscript
2012-04-18 11:57:54 -07:00
ssuda
70005be4ff Fixing ClientRequest setTimeout EventEmitter Leak
This will fix #3068
2012-04-16 23:36:18 +02:00
Ben Noordhuis
16fca262be net: honor 'enable' flag in .setNoDelay()
Fixes #3096.
2012-04-12 19:15:32 +02:00
Igor Zinkovsky
0dcc43316f don't crash when queued write fails 2012-03-22 17:09:22 -07:00
Dmitry Nizovtsev
1e9bcf26ce net, http, https: add localAddress option
Binds to a local address before making the outgoing connection.
2012-03-06 13:35:49 +01:00
koichik
cd5d2473a4 net: fix race write() before and after connect()
Fixes #2827.
2012-02-28 19:57:13 +09:00
koichik
63431796f4 net: fix race write() before and after connect()
Fixes #2827.
2012-02-28 19:27:27 +09:00
Mikeal Rogers
d530ee62cd Issue #2762. Add callback to close function. 2012-02-18 17:46:28 -08:00
isaacs
0cdf85e28d Lint all the JavaScripts. 2012-02-18 15:34:57 -08:00
isaacs
a2851b6234 Revert "cluster: propagate bind errors"
This reverts commit 30e462e919.
2012-02-17 12:39:45 -08:00
Ben Noordhuis
30e462e919 cluster: propagate bind errors
This commit fixes a bug where the cluster module failed to propagate EADDRINUSE
errors.

When a worker starts a (net, http) server, it requests the listen socket from
its master who then creates and binds the socket.

Now, OS X and Windows don't always signal EADDRINUSE from bind() but instead
defer the error until a later syscall. libuv mimics this behaviour to provide
consistent behaviour across platforms but that means the worker could end up
with a socket that is not actually bound to the requested addresss.

That's why the worker now checks if the socket is bound, raising EADDRINUSE if
that's not the case.

Fixes #2721.
2012-02-16 23:47:17 +01:00
Ben Noordhuis
8a6576f764 Merge remote-tracking branch 'origin/v0.6'
Conflicts:
	common.gypi
2012-02-12 16:12:26 +01:00
Igor Zinkovsky
c7771bc2ec set readable/writable for pipes 2012-02-10 11:28:43 -08:00
isaacs
116835561d Merge remote-tracking branch 'ry/v0.6'
Conflicts:
	ChangeLog
	deps/v8/src/version.cc
	deps/v8/tools/gyp/v8.gyp
	doc/about/index.html
	doc/community/index.html
	doc/index.html
	doc/logos/index.html
	doc/template.html
	lib/path.js
	lib/querystring.js
	src/node_version.h
2012-02-06 15:43:21 -08:00
koichik
0f0af55a0a net: fix large file downloads failing
Fixes #2678.
2012-02-05 17:41:49 +09:00
Stefan Rusu
4671e54495 net: destroy socket on DNS error
The socket was never destroyed on DNS errors. This broke some clients, including
lib/https.js.
2012-02-04 00:40:53 +01:00
Igor Zinkovsky
db3c4efd1d support for sharing streams accross isolates 2012-01-31 17:45:50 -08:00
Ben Noordhuis
e806ad39d0 net, tls, http: remove socket.ondrain
Replace the ondrain hack with a regular 'drain' listener. Speeds up the
bytes/1024 http benchmark by about 1.2%.
2012-01-24 15:57:50 +01:00
Ryan Dahl
ca2a047b8e Merge remote branch 'origin/v0.6'
Conflicts:
	deps/uv/src/win/util.c
	src/udp_wrap.cc
2012-01-16 15:20:26 -08:00
Ben Noordhuis
f0c1376e07 net: make .write() throw on bad input
Passing a non-buffer or non-string argument to Socket.prototype.write triggered
an assert:

  Assertion failed: (Buffer::HasInstance(args[0])), function Write,
  file ../src/stream_wrap.cc, line 289.

Fixes #2532.
2012-01-14 02:13:24 +01:00
koichik
70033bd960 net: make connect() accept options
This makes API even with tls.connect().
Refs #1983.

See also:
http://groups.google.com/group/nodejs-dev/msg/3b6dbcc4a9a82d99

Fixes #2487.
2012-01-09 02:18:39 +01:00
Andreas Madsen
5f08c3cfa1 cluster improvements: Worker class and isolate internal messages
Fixes #2388
2012-01-04 18:30:19 -08:00
Ben Noordhuis
c24276f008 net: defer net.Server 'close' event to next tick 2011-12-29 19:30:07 +01:00
koichik
a848a3efbf net: fix Socket.pause null reference when called on a closed Stream
Fixes #1980.
2011-12-28 15:13:57 +09:00
Ju-yeong Park
5976d58796 net: raise exception when the socket is closed 2011-12-22 17:25:14 +01:00
James Hartig
348d8cd04a timers: remove _idleTimeout from item in .unenroll()
Stops .active() from reactivating the timer.

Fixes #2114.
2011-12-20 00:57:15 +01:00
Ben Noordhuis
8295c80618 net: check status code in afterWrite
Fixes memory leak and spin on writing to dead fds. This was tested in
production.
2011-12-12 13:45:44 -08:00
isaacs
580e67015c Apply #2257 fix for Pipe streams as well as TTYs 2011-12-06 10:13:31 -08:00
isaacs
cf20b6bf65 Fix #2257 pause/resume semantics for stdin
This makes it so that the stdin TTY-wrap stream gets ref'ed on
.resume() and unref'ed on .pause()

The semantics of the names "pause" and "resume" are a bit weird, but the
important thing is that this corrects an API change from 0.4 -> 0.6
which made it impossible to read from stdin multiple times, without
knowing when it might end up being closed.  If no one has it open, this
lets the process die naturally.

LGTM'd by @ry
2011-12-05 16:47:11 -08:00
isaacs
db273818f6 s/NPM/npm/
http://npmjs.org/doc/faq.html#If-npm-is-an-acronym-why-is-it-never-capitalized
2011-12-05 16:20:44 -08:00
Igor Zinkovsky
99c9d19184 binding for uv_pipe_pending_instances 2011-12-01 13:57:47 -08:00
Ben Noordhuis
03eb41c2ec net: don't emit 'close' event twice
Don't allow `socket.destroy()` to run twice. The self-destruct sequence itself
is idempotent but it makes the 'close' and 'error' events fire more than once,
which may confuse listeners.

Fixes #2223.
2011-12-01 14:57:06 +01:00
Ryan Dahl
86528489ec new cluster api 2011-11-04 15:12:11 -07:00
Ryan Dahl
4a8088a603 Socket.write should reset timeout timer.
Fixes #2002.
2011-11-03 12:37:04 -07:00
Ben Noordhuis
9c11e8a1ca net: implement Server.prototype.address() for pipes 2011-11-03 19:16:10 +01:00
Ryan Dahl
60818b957c Add missing copyright headers 2011-11-02 10:00:57 -07:00
Maciej Małecki
7ee29d1d5b net: Server.listen, Server.close and Socket.connect return this
Just a syntactic sugar for doing, for example:

    var server = net.createServer(function (c) {
      c.end('goodbye, cruel world!\r\n');
      server.close().on('close', function () {
        console.log('really, goodbye!');
      });
    }).listen(1337);

Fixes #1922.
2011-10-24 22:19:42 +09:00
Ben Noordhuis
ac379b3be1 net: bring back .setNoDelay() and .setKeepAlive() 2011-10-21 18:09:23 -07:00
Ryan Dahl
6cc0c9e6a9 Remove superfluous nextTick during server binding
This breaks fork().send({}, server._handle) after server.listen() because
server._handle is not set.
2011-10-18 15:12:18 -07:00
koichik
d6191f593d net: fix error handling in listen()
Fixes #1894.
2011-10-16 01:30:19 +09:00
Ben Noordhuis
0b92fa0e93 net: fix connect queue bugs
This commit fixes two bugs in the handling of write requests when the connect()
call is still in progress.

1. The deferred write request's size was counted twice towards `.bytesWritten`.

2. The callback was not called. After connecting, `Socket.write()` was called
   with three arguments (data, encoding, cb) but it ignored the third argument.

Coincidentally fixes test/simple/test-net-connect-buffer.js.
2011-10-15 03:34:09 +02:00
Ben Noordhuis
6df574b744 net: properly account multi-byte chars in .bytesWritten 2011-10-15 03:24:34 +02:00
Simen Brekken
4b0e36810a net: register net.Server callback only once
Only register once for listening when passing a callback to Server.listen(),
this prevents servers recycled using close() from invoking the callback when
Server.listen() is called later.
2011-10-13 16:09:14 +02:00
Ryan Dahl
25ff181300 Revert some changes made in 12486a6
Some of the perf improvements from many-writes-fix branch were accidentally
undone in that commit. This puts them back in.
2011-10-12 12:49:58 -07:00
Ryan Dahl
87339a22b1 introduce node cluster 2011-10-12 02:58:35 -07:00
Ryan Dahl
be0bb2dc13 Remove net_legacy timers_legacy 2011-10-11 13:11:54 -07:00
Ryan Dahl
710f8e2acc Add --use-uv command-line flag to use libuv backend 2011-06-17 13:51:40 +02:00
Felix Geisendörfer
f0a440d886 Remove 'connect' event from server side sockets
Sockets emitted by the 'connection' event are always connected, having
them emit the 'connect' event makes no sense. It only confused people,
as it's not clear if you have to listen to 'connect' or not.

That try..catch block was also very scary. It would silently swallow
exceptions in 'connect' listeners and destroy the socket. Makes no
sense.

Fixes #1047.
2011-05-24 11:22:59 -07:00
Ryan Dahl
9e6498d5fa Merge branch 'v0.4'
Conflicts:
	src/node_version.h
2011-04-18 18:58:16 -07:00
Ryan Dahl
8417870f51 Don't emit error on ECONNRESET - just close
Fix #670
2011-04-14 10:42:57 -07:00
Ryan Dahl
598792ba91 Merge branch 'v0.4'
Conflicts:
	src/platform_sunos.cc
	test/simple/test-os.js
2011-04-14 01:11:21 +00:00
Brian White
ac1da4b407 Add remoteAddress and remotePort for client TCP connections
https://groups.google.com/d/topic/nodejs-dev/Asr87_YFSkg/discussion
2011-04-13 10:24:28 -07:00
Ryan Dahl
9ccf0e527f Don't error on ENOTCONN from shutdown() 2011-04-11 15:33:24 -07:00
Ryan Dahl
7a8c729830 Merge branch 'v0.4'
Conflicts:
	src/node_version.h
2011-03-22 13:12:07 -07:00
Ryan Dahl
d7a86ff05e Fix GH-819. Drop out if connection destroyed before connect() 2011-03-21 14:48:26 -07:00
Daniel Ennis
911cbd0cef Add support for file descriptor type detection.
setImplementationMethods checks the type of a socket and defines different
behavior based on the type, so auto detect it if type not implicitly
specified.
2011-03-17 10:35:47 -07:00
Ryan Dahl
55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
koichik
414fa4abae Better type checks for fd in net.js 2011-03-11 16:34:12 -08:00
koichik
113b1e6e0c Fix GH-746 process.stdin.destroy() breaks http server 2011-03-11 16:33:07 -08:00
Andreas Reich
5e91042fcb Don't decrease server connection counter again if destroy() is called more than once
Test: Anders Conbere <aconbere@gmail.com>
Fix: Andreas Reich <andreas@reich.name>

Closes GH-431.
Closes GH-502.
2011-03-04 15:45:12 -08:00
Ryan Dahl
e9257b859d New DTrace probes from CA team 2011-02-09 18:50:26 -08:00
Ryan Dahl
a48a075535 better debug messages in net and tls 2011-02-09 10:23:26 -08:00
Ryan Dahl
4733d0b1f0 http: handle aborts 2011-02-04 18:07:00 -08:00
Ryan Dahl
9f3a20c76d net: Add hook for when writeQueue changes 2011-01-31 11:01:59 -08:00
Ryan Dahl
6ede26cb9c Add socket.bufferSize 2011-01-31 10:41:52 -08:00
Ryan Dahl
bfb6a67d60 Another fix for process.assert 2011-01-27 16:59:28 -08:00
Ali Farhadi
c70dd70301 Adding callback parameter to Socket's setTimeout method. 2011-01-26 12:13:03 -08:00
Ryan Dahl
068b733583 Land Cantrill's DTrace patch
only works on solaris
2011-01-24 18:59:06 -08:00
Ryan Dahl
9e976abad9 lint 2011-01-24 10:55:30 -08:00
Ryan Dahl
b22b5e341b listen/bind errors should close net.Server 2011-01-18 16:22:43 -08:00
Bert Belder
0eb4c2157d Define winsock error numbers 2011-01-18 04:58:30 +01:00
Ryan Dahl
5f5201db2f Fix test-net-connect-buffer
Change to end() behavior in 33c339 was breaking it. end() should wait for
connection before dumping. Changed test-net-connect-timeout to use destroy()
instead.
2011-01-12 13:29:45 -08:00
Ryan Dahl
5f795efd4e net: Timeouts should work before DNS resolution 2011-01-12 12:59:58 -08:00
Ryan Dahl
33c33949b2 Add test for connection timeouts
Also make socket.end() destroy connection if still trying to connect.
Previously was ignoring.
2011-01-12 10:57:03 -08:00
Ryan Dahl
5a05992155 Lint 2011-01-06 16:06:27 -08:00
Ryan Dahl
b62152bc84 Rename net.Stream to net.Socket 2011-01-05 11:53:56 -08:00
Ryan Dahl
bc1d758408 net.js: Check that readWatcher exists before pause, resume 2011-01-04 11:25:36 -08:00
Ryan Dahl
2957382991 Implement new stream method, destroySoon
Still missing on fs.WriteStream
2011-01-04 11:22:19 -08:00
Ryan Dahl
e4dd5cd6fd NODE_DEBUG uses strings instead of bitflags 2011-01-03 15:41:58 -08:00
Ryan Dahl
632da2a393 Add callback paramenter to socket.connect() 2010-12-15 15:57:41 -08:00
Ryan Dahl
c4161f32f5 Add callback to socket.write() 2010-12-15 15:47:02 -08:00
Ryan Dahl
c970968ee6 better option parsing for socket.write() 2010-12-15 15:15:27 -08:00
Ryan Dahl
92789b16e5 Fix global leaks 2010-12-04 16:36:21 -08:00
Ryan Dahl
e232f6e735 more lint 2010-12-01 20:28:28 -08:00
Ryan Dahl
ec1589875c Stop watcher before calling .set() in Stream.prototype.resume 2010-12-01 12:52:34 -08:00
Ryan Dahl
a6f6532dfb Fix test-securepair-server 2010-11-23 18:30:52 -08:00
Ryan Dahl
2320497992 Revert "Merge branch 'writev'"
This reverts commit cd9515efd9, reversing
changes made to df46c8e698.

Too slow. Needs more work.
2010-11-20 20:55:15 -08:00
Ryan Dahl
1f18648394 Fix typo 2010-11-18 16:47:38 -08:00
Ryan Dahl
2ba3c10d62 Only try to flush big buffers once 2010-11-18 16:47:38 -08:00
Ryan Dahl
849792e46b Add todo about test-pipe.js and throwing on resume() 2010-11-18 16:47:38 -08:00
Ryan Dahl
544877d12e Fix socket.end() problem on non-empty queue 2010-11-18 16:47:38 -08:00
Ryan Dahl
3884b4185a Small clean ups 2010-11-18 16:47:38 -08:00
Ryan Dahl
02039c9b53 'connect' event may disconnect socket 2010-11-18 16:47:38 -08:00
Ryan Dahl
fa556a1425 Add callback to socket.write(), fix test-sendfds 2010-11-18 16:47:38 -08:00
Ryan Dahl
a6d8425382 make sure unix sockets are tagged correctly 2010-11-18 16:47:38 -08:00
Ryan Dahl
5d6a03c9fe Don't append buckets of zero length 2010-11-18 16:47:38 -08:00
Ryan Dahl
10ff559ec3 Add IOWatcher.flush()
To be called if sockets get too much data. This is to force a flush before
the tick ends.
2010-11-18 16:47:37 -08:00
Ryan Dahl
7c3c5c6861 Maintain queueSize for each socket 2010-11-18 16:47:37 -08:00
Ryan Dahl
5a84461e46 Also do ondrain callback for socket (needed by http) 2010-11-18 16:47:37 -08:00
Ryan Dahl
e1250a3333 Reset _eof on socket reuse 2010-11-18 16:47:37 -08:00
Ryan Dahl
5ba0be6166 Don't send null data segments 2010-11-18 16:47:37 -08:00
Ryan Dahl
dcc547d798 Dumper net.js integration 2010-11-18 16:47:37 -08:00
Ryan Dahl
df46c8e698 Rip out the old TLS implementation 2010-11-18 16:46:37 -08:00
Ryan Dahl
cf05257fb7 Test for server.listen() more carefully, fix bug 2010-11-16 15:33:21 -08:00
Ryan Dahl
4144024e6b Test and fix for self-assigned port from net.Server 2010-11-15 20:22:54 -08:00
Ryan Dahl
f1391f33cd Add missing require('fs') 2010-11-01 14:56:21 -07:00
Ryan Dahl
1eb547fec1 Lazy load modules in net.js 2010-10-28 13:15:53 -07:00
Ryan Dahl
5171da5a6c Remove a little redundancy 2010-10-28 13:11:42 -07:00
Ryan Dahl
65dced730f Handle one more onReadable call from crypto
MUST get rid of this calledByIOWatcher stuff. Hopefully will be able to when
securepair stuff lands.
2010-10-28 12:34:48 -07:00
Ryan Dahl
73cfda12bb Abstract out a Server.prototype.pause method 2010-10-28 11:42:22 -07:00
Ryan Dahl
ad61d77fa3 Abstract out net.Server.prototype._rejectPending
Does the same timeout action for maxConnections as it does for EMFILE.
2010-10-28 11:33:35 -07:00
Jonas Pfenniger
74d0a077ec Module-level EMFILE handling
All net servers now share the same dummy socket. The ulimit warning is
throttled for all servers.
2010-10-28 11:12:59 -07:00
Ryan Dahl
67652ddf27 Refactor callbacks in net.Stream for fewer closures 2010-10-27 16:43:16 -07:00
Ryan Dahl
38dde9684f Add extra anti-DoS tech to net.Server 2010-10-27 12:09:16 -07:00
Ryan Dahl
ac54272218 Gracefully handle EMFILE
Implementing a tip from Marc Lehmann:
http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#The_special_problem_of_accept_ing_wh

Keep an extra FD around for every server. When you hit EMFILE, destroy that
FD, accept a connection, close it; in this way you can clear the connection
queue and let people know that you're overload.

No more timeout needed.
2010-10-27 02:12:25 -07:00
Ryan Dahl
5cc29b80f2 Move idle timers into its own module 2010-10-26 14:53:17 -07:00
Ryan Dahl
2470d2ee92 allowHalfOpen disabled by default
Users too often would forget to add

  socket.on('end', function () {
    socket.end();
  });

Which is a mistake. Therefore we default to this behavior and
only optionally let people handle the 'end' case themselves.
2010-10-26 01:10:18 -07:00
Micheil Smith
8da020d39e Update node_net.cc to make us of node_constants.cc
also affects dgram which uses a constant from node_net.cc
2010-10-25 12:14:47 -07:00
Ryan Dahl
0ac2ef924f Do not spin on aceept() with EMFILE
When a server hit EMFILE it would continue to try to accept new connections
from the queue. This patch introduces a timeout of one second where it will
stop trying to accept new files. After the second is over it tries again.

This is a rather serious bug that has been effecting many highly concurrent
programs. It was introduced in 4593c0, version v0.2.0.

TODO: A test for this situation. Currently I test it like this

  termA% cd projects/node
  termA% ulimit -n 256
  termA% ./node benchmark/idle_server.js

  termB% cd projects/node
  termB% ./node benchmark/idle_clients.js

And watch how the server process behaves.
2010-10-23 12:28:20 -07:00
Ryan Dahl
d9a5edb2b0 Fix test-net-eaddrinuse 2010-10-23 11:22:24 -07:00
Jorge Chamorro Bieling
99e19aa398 Remove unneeded function wrappers 2010-10-21 17:11:59 -07:00
Johan Euphrosine
5d400cfd3a net listen should emit eaddrinuse error 2010-10-18 17:00:13 -07:00
Joshua Peek
73b29d79b9 Don't flush net writeQueue on end() if its still connecting 2010-10-13 02:37:53 -07:00
Ryan Dahl
6691aca229 Allow people to set backlog. Need a better API. 2010-10-13 01:47:29 -07:00
Micheil Smith
a3604cf233 Removed deprecated methods from lib/net.js 2010-10-11 16:20:08 -07:00
Micheil Smith
83db91be41 Removed deprecated alias to lib/fs.js 2010-10-11 16:20:04 -07:00
Ryan Dahl
7e24a05cba Fix test-http-buffer-sanity 2010-10-11 16:00:36 -07:00
Micheil Smith
e38eb0c5a4 Soft migration of sys -> util, Removal of deprecated utils module. 2010-10-11 15:21:36 -07:00
Ryan Dahl
1d3142a882 TCP clients should buffer writes before connection 2010-10-10 23:09:14 -07:00
Ryan Dahl
bc695475b9 Add Stream base class with stream.pipe 2010-10-10 17:27:03 -07:00
Joshaven Potter
3d4e4d8909 syntax fixes to pass jslint 2010-10-06 20:40:57 -07:00
Ryan Dahl
f323f34353 writeable -> writable 2010-09-29 16:12:30 -07:00
Ryan Dahl
9911629de0 Fix style in node_crypto.cc 2010-09-28 19:17:09 -07:00
Ryan Dahl
163485c8aa Rename some SecureStream methods 2010-09-28 11:38:27 -07:00
Ryan Dahl
7bd94712a8 lazy load crypto binding 2010-09-28 11:27:13 -07:00
Ryan Dahl
d89f8dce28 fix style in net.js 2010-09-28 11:27:09 -07:00
Ryan Dahl
069d973d74 Remove require('buffer') in built-in libraries. 2010-09-28 02:31:31 -07:00
Ryan Dahl
01b3418e2e Move IOWatcher and Timer to process.binding 2010-09-17 00:15:54 -07:00
Paul Querna
c8f9728de7 Move dns.isIP to net.isIP
Add tests and docs.
2010-09-16 17:27:10 -07:00
Ryan Dahl
251d03197f Remove deprecation warnings in net module 2010-09-16 15:02:12 -07:00
Bradley Meck
d5214b3627 Allow Strings for ports on net.Server.listen 2010-08-30 13:27:38 -07:00
Ryan Dahl
4fdebab005 Safe constructor: net.Server, net.Stream 2010-08-27 15:38:46 -07:00
Ryan Dahl
4593c04959 Implement net.Server.maxConnections
Simplify EMFILE behavior.
2010-08-15 14:01:55 -07:00
Illarionov Oleg
cde80d9859 Fix OpenSSL 100% CPU usage on error 2010-08-15 13:23:09 -07:00
Matt Ranney
f7c5334195 Check for socket on Unix domain connect.
Change scope to context in REPL docs.
2010-07-26 19:02:15 -07:00
Peter Griess
94cd83ef34 Doc fixes for FD related features, upgrade.
- Add docs for 'fd' events, Server.listenFD(), Stream.write(...[, fd])
  and http.Client 'upgrade' event.
2010-07-03 08:18:42 +02:00
Blake Mizerany
8c8534046c fix whitespace errors 2010-06-29 23:59:24 -07:00
Ryan Dahl
7b119f8b38 Fix error message 2010-06-23 09:09:15 -07:00
Ryan Dahl
6bed15e074 Refactor: Utf8Decoder -> StringDecoder
Instead of just decoding Utf8, this will proxy requests to buffer.toString()
for other encodings. This makes for a simpler interface.
2010-06-15 18:19:27 -07:00