lib: don't use emitter.listeners(type).length

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
querystring: remove prepended ? from query field

Fixes an issue that caused the first querystring to be parsed prepending
a "?" in the first variable name on relative urls with no #fragment

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
doc: typo fixes on stream, tls and http

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
dgram: remove new keyword from errnoException

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
src: require EventEmitter via NativeModule

Fixes a recent change causing test-process-kill-pid.js to fail.

Fixes: 931cbc1 "lib: don't use emitter.listeners(type).length"
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
src: change kIsolateSlot to 3

The slot 0 and 1 had already been taken by "gin" and "blink" in Chrome,
and the size of isolate's slots is 4 by default, so using 3 should hopefully
make node work independently when embedded into other application.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
tests: fix invalid hints flags dns test.

1 is actually a valid flag on SmartOS. More generally, hints flags'
values are defined by the underlying native flags, and these can have
different values on different systems.

Using (ADDRCONFIG | V4MAPPED) + 1 ensure that the flag will be invalid,
since it will always be different from ADDRCONFIG, V4MAPPED, ADDRCONFIG
| V4MAPPED,  0 and any other combination of even flags.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
tests: do not hardcode service name in test-dns.

Instead of hard-coding http service name in test-dns, retrieve it from
/etc/services. This is not ideal, but it's still better than hard-coding
it.

Fixes #8047.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
test: check ipv6 support before testing it

fix #7983
fix #8049

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
tests: don't assume IPv4 only in remote addr tests

Tests in test-net-remote-address-port.js assume that client and server
sockets always use IPv4. However, depending on the OS and the network
interfaces setup, this is not true. This change makes the test consider
that both IPv4 or IPv6 sockets are valid

Fixes #8096.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
test: fix dns test

Fix a few issues in test/internet/test-dns.js:
- 'hint' should be 'hints'
- reverse name lookup is not guaranteed to return 'localhost'
- V4MAPPED hint requires IPV6 address family

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
module: normalize path when computing cache key.

When adding a new module to the cache, and also when querying the cache,
normalize the path so that modules don't get loaded more than once when:
- They are referenced by the same filename but with different case for
  the drive letter on Windows.
- They are referenced by two different paths that point to the same
  file.

Fixes #7031.