Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
@@ -1,5 +1,5 @@
{
"version": "1.3.11",
"version": "1.3.13",
"name": "npm",
"publishConfig": {
"proprietary-attribs": false
@@ -34,7 +34,7 @@
"main": "./lib/npm.js",
"bin": "./bin/npm-cli.js",
"dependencies": {
"semver": "~2.1.0",
"semver": "~2.2.1",
"ini": "~1.1.0",
"slide": "~1.1.5",
"abbrev": "~1.0.4",
@@ -47,34 +47,35 @@
"tar": "~0.1.18",
"fstream": "~0.1.23",
"block-stream": "0.0.7",
"mkdirp": "~0.3.3",
"mkdirp": "~0.3.5",
"read": "~1.0.4",
"lru-cache": "~2.3.1",
"node-gyp": "~0.10.10",
"fstream-npm": "~0.1.3",
"node-gyp": "~0.11.0",
"fstream-npm": "~0.1.6",
"uid-number": "0",
"archy": "0",
"chownr": "0",
"npmlog": "0.0.4",
"ansi": "~0.1.2",
"npm-registry-client": "~0.2.28",
"read-package-json": "~1.1.3",
"npmlog": "0.0.6",
"ansi": "~0.2.1",
"npm-registry-client": "~0.2.29",
"read-package-json": "~1.1.4",
"read-installed": "~0.2.2",
"glob": "~3.2.6",
"init-package-json": "0.0.11",
"osenv": "0",
"lockfile": "~0.4.0",
"retry": "~0.6.0",
"once": "~1.1.1",
"npmconf": "~0.1.2",
"once": "~1.3.0",
"npmconf": "~0.1.5",
"opener": "~1.3.0",
"chmodr": "~0.1.0",
"cmd-shim": "~1.0.1",
"cmd-shim": "~1.1.1",
"sha": "~1.2.1",
"editor": "0.0.4",
"editor": "0.0.5",
"child-process-close": "~0.1.1",
"npm-user-validate": "0.0.3",
"github-url-from-git": "1.1.1"
"github-url-from-git": "1.1.1",
"github-url-from-username-repo": "0.0.2"
},
"bundleDependencies": [
"semver",
@@ -118,12 +119,14 @@
"child-process-close",
"editor",
"npm-user-validate",
"github-url-from-git"
"github-url-from-git",
"github-url-from-username-repo",
"normalize-package-data"
],
"devDependencies": {
"ronn": "~0.3.6",
"tap": "~0.4.0",
"npm-registry-mock": "~0.3.0"
"npm-registry-mock": "~0.5.3"
},
"engines": {
"node": ">=0.6",
@@ -132,7 +135,7 @@
"scripts": {
"test": "node ./test/run.js && tap test/tap/*.js",
"tap": "tap test/tap/*.js",
"prepublish": "node bin/npm-cli.js prune ; rm -rf test/*/*/node_modules ; make -j4 doc",
"prepublish": "node bin/npm-cli.js prune --prefix=. --no-global && rm -rf test/*/*/node_modules && make -j4 doc",
"dumpconf": "env | grep npm | sort | uniq",
"echo": "node bin/npm-cli.js"
},
@@ -1,8 +1,8 @@
{
"npm-test-peer-deps-file": {
"version": "1.2.3",
"from": "https://raw.github.com/gist/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js",
"resolved": "https://raw.github.com/gist/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js",
"from": "https://gist.github.com/domenic/3971128/raw/7472b26a013ceb174c2d726314e9fa97465729bb/index.js",
"resolved": "https://gist.github.com/domenic/3971128/raw/7472b26a013ceb174c2d726314e9fa97465729bb/index.js",
"dependencies": {
"opener": {
"version": "1.3.0",
@@ -3,7 +3,7 @@
"name": "npm-test-peer-deps",
"version": "0.0.0",
"dependencies": {
"npm-test-peer-deps-file": "https://raw.github.com/gist/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js"
"npm-test-peer-deps-file": "https://gist.github.com/domenic/3971128/raw/7472b26a013ceb174c2d726314e9fa97465729bb/index.js"
},
"scripts": {
"test": "node test.js"
@@ -3,7 +3,7 @@
"name": "npm-test-shrinkwrap",
"version": "0.0.0",
"dependencies": {
"npm-test-single-file": "https://raw.github.com/gist/1837112/index.js",
"npm-test-single-file": "https://gist.github.com/isaacs/1837112/raw/9ef57a59fc22aeb1d1ca346b68826dcb638b8416/index.js",
"glob": "git://github.com/isaacs/node-glob.git#npm-test",
"minimatch": "~0.1.0"
},

This file was deleted.

This file was deleted.

@@ -0,0 +1,12 @@
var test = require('tap').test
var spawn = require('child_process').spawn
var node = process.execPath
var npm = require.resolve('../../')
var args = [ npm, 'ls', 'ceci n’est pas une package' ]
test('ls exits non-zero when nothing found', function (t) {
var child = spawn(node, args)
child.on('exit', function (code) {
t.notEqual(code, 0)
t.end()
})
})
@@ -0,0 +1,23 @@
var test = require("tap").test
var npm = require("../../")

var mr = require("npm-registry-mock")

// config
var port = 1331
var address = "http://localhost:" + port
var pkg = __dirname + '/outdated-include-devdependencies'


test("includes devDependencies in outdated", function (t) {
process.chdir(pkg)
mr(port, function (s) {
npm.load({registry: address}, function () {
npm.outdated(function (er, d) {
t.equal("1.5.1", d[0][3])
s.close()
t.end()
})
})
})
})
@@ -0,0 +1,8 @@
{
"author": "Rocko Artischocko",
"name": "ignore-shrinkwrap",
"version": "0.0.0",
"devDependencies": {
"underscore": ">=1.3.1"
}
}
@@ -0,0 +1,38 @@
var test = require("tap").test
var npm = require("../../")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")


var mr = require("npm-registry-mock")

// config
var port = 1331
var address = "http://localhost:" + port
var pkg = __dirname + "/outdated-new-versions"
mkdirp.sync(pkg + "/cache")


test("dicovers new versions in outdated", function (t) {
process.chdir(pkg)
t.plan(2)
mr(port, function (s) {
npm.load({cache: pkg + "/cache", registry: address}, function () {
npm.outdated(function (er, d) {
for (var i = 0; i < d.length; i++) {
if (d[i][1] === "underscore")
t.equal("1.5.1", d[i][4])
if (d[i][1] === "request")
t.equal("2.27.0", d[i][4])
}
s.close()
t.end()
})
})
})
})

test("cleanup", function (t) {
rimraf.sync(pkg + "/cache")
t.end()
})
@@ -0,0 +1,11 @@
{
"name": "new-versions-with-outdated",
"author": "Rockbert",
"version": "0.0.0",
"dependencies": {
"underscore": "~1.3.1"
},
"devDependencies": {
"request": "~0.9.0"
}
}
@@ -0,0 +1,90 @@
// verify that prepublish runs on pack and publish
var test = require('tap').test
var npm = require('../../')
var fs = require('fs')
var pkg = __dirname + '/prepublish_package'
var tmp = pkg + '/tmp'
var cache = pkg + '/cache'
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var path = require('path')
var os = require('os')

test('setup', function (t) {
var n = 0
mkdirp(pkg, then())
mkdirp(cache, then())
mkdirp(tmp, then())
function then (er) {
n ++
return function (er) {
if (er)
throw er
if (--n === 0)
next()
}
}

function next () {
fs.writeFile(pkg + '/package.json', JSON.stringify({
name: 'npm-test-prepublish',
version: '1.2.5',
scripts: { prepublish: 'echo ok' }
}), 'ascii', function (er) {
if (er)
throw er
t.pass('setup done')
t.end()
})
}
})

test('test', function (t) {
var spawn = require('child_process').spawn
var node = process.execPath
var npm = path.resolve(__dirname, '../../cli.js')
var env = {
npm_config_cache: cache,
npm_config_tmp: tmp,
npm_config_prefix: pkg,
npm_config_global: 'false'
}
for (var i in process.env) {
if (!/^npm_config_/.test(i))
env[i] = process.env[i]
}
var child = spawn(node, [npm, 'pack'], {
cwd: pkg,
env: env
})
child.stdout.setEncoding('utf8')
child.stderr.on('data', function(chunk) {
throw new Error('got stderr data: ' + JSON.stringify('' + chunk))
})
child.stdout.on('data', ondata)
child.on('close', onend)
var c = ''
function ondata (chunk) {
c += chunk
}
function onend () {
c = c.trim()
t.equal( c
, '> npm-test-prepublish@1.2.5 prepublish .' + os.EOL
+ '> echo ok' + os.EOL
+ os.EOL
+ 'ok' + os.EOL
+ 'npm-test-prepublish-1.2.5.tgz')
t.end()
}
})

test('cleanup', function (t) {
rimraf(pkg, function(er) {
if (er)
throw er
t.pass('cleaned up')
t.end()
})
})

@@ -1,5 +1,6 @@
var test = require('tap').test
var fs = require('fs')
var osenv = require('osenv')
var pkg = process.env.npm_config_tmp || '/tmp'
pkg += '/npm-test-publish-config'

@@ -41,7 +42,8 @@ test(function (t) {
npm_config_cache_lock_wait: 1000,
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH
PATH: process.env.PATH,
USERPROFILE: osenv.home()
}
})
})
@@ -0,0 +1,24 @@
var test = require("tap").test
, npm = require("../../")

test("returns a list of removed items", function (t) {
t.plan(1)

setup(function () {
npm.install(".", function (err) {
if (err) return t.fail(err)
npm.uninstall("once", "ini", "lala", function (err, d) {
if (err) return t.fail(err)
t.same(d.sort(), ["once", "ini"].sort())
t.end()
})
})
})
})

function setup (cb) {
process.chdir(__dirname + "/uninstall-package")
npm.load(function () {
cb()
})
}
@@ -0,0 +1,9 @@
{
"name": "beep",
"version": "0.0.0",
"main": "index.js",
"dependencies": {
"once": "*",
"ini": "*"
}
}
@@ -8,8 +8,8 @@
core
vgcore.*
.buildstamp

/.deps/
.dirstamp
.deps/
/.libs/
/aclocal.m4
/ar-lib
@@ -6,6 +6,7 @@ Brian White <mscdex@mscdex.net>
Brian White <mscdex@mscdex.net> <mscdex@gmail.com>
Frank Denis <github@pureftpd.org>
Isaac Z. Schlueter <i@izs.me>
Keno Fischer <kenof@stanford.edu> <kfischer+github@college.harvard.edu>
Keno Fischer <kenof@stanford.edu> <kfischer@college.harvard.edu>
Robert Mustacchi <rm@joyent.com> <rm@fingolfin.org>
Ryan Dahl <ryan@joyent.com> <ry@tinyclouds.org>
@@ -92,3 +92,8 @@ Andrei Sedoi <bsnote@gmail.com>
Navaneeth Kedaram Nambiathan <navaneethkn@gmail.com>
Alex Crichton <alex@alexcrichton.com>
Brent Cook <brent@boundary.com>
Brian Kaisner <bkize1@gmail.com>
Luca Bruno <lucab@debian.org>
Reini Urban <rurban@cpanel.net>
Maks Naumov <maksqwe1@ukr.net>
Sean Farrell <sean.farrell@rioki.org>
@@ -1,4 +1,152 @@
2013.09.05, Version 0.11.13 (Unstable)
2013.10.30, Version 0.11.14 (Unstable)

Changes since version 0.11.13:

* darwin: create fsevents thread on demand (Ben Noordhuis)

* fsevents: FSEvents is most likely not thread-safe (Fedor Indutny)

* fsevents: use shared FSEventStream (Fedor Indutny)

* windows: make uv_fs_chmod() report errors correctly (Bert Belder)

* windows: make uv_shutdown() for write-only pipes work (Bert Belder)

* windows/fs: wrap multi-statement macros in do..while block (Bert Belder)

* windows/fs: make uv_fs_open() report EINVAL correctly (Bert Belder)

* windows/fs: handle _open_osfhandle() failure correctly (Bert Belder)

* windows/fs: wrap multi-statement macros in do..while block (Bert Belder)

* windows/fs: make uv_fs_open() report EINVAL correctly (Bert Belder)

* windows/fs: handle _open_osfhandle() failure correctly (Bert Belder)

* build: clarify instructions for Windows (Brian Kaisner)

* build: remove GCC_WARN_ABOUT_MISSING_NEWLINE (Ben Noordhuis)

* darwin: fix 10.6 build error in fsevents.c (Ben Noordhuis)

* windows: run close callbacks after polling for i/o (Saúl Ibarra Corretgé)

* include: clarify uv_tcp_bind() behavior (Ben Noordhuis)

* include: clean up includes in uv.h (Ben Noordhuis)

* include: remove UV_IO_PRIVATE_FIELDS macro (Ben Noordhuis)

* include: fix typo in comment in uv.h (Ben Noordhuis)

* include: update uv_is_active() documentation (Ben Noordhuis)

* include: make uv_process_options_t.cwd const (Ben Noordhuis)

* unix: wrap long lines at 80 columns (Ben Noordhuis)

* unix, windows: make uv_is_*() always return 0 or 1 (Ben Noordhuis)

* bench: measure total/init/dispatch/cleanup times (Ben Noordhuis)

* build: use -pthread on sunos (Timothy J. Fontaine)

* windows: remove duplicate check in stream.c (Ben Noordhuis)

* unix: sanity-check fds before closing (Ben Noordhuis)

* unix: remove uv__pipe_accept() (Ben Noordhuis)

* unix: fix uv_spawn() NULL pointer deref on ENOMEM (Ben Noordhuis)

* unix: don't close inherited fds on uv_spawn() fail (Ben Noordhuis)

* unix: revert recent FSEvent changes (Ben Noordhuis)

* fsevents: fix clever rescheduling (Fedor Indutny)

* linux: ignore fractional time in uv_uptime() (Ben Noordhuis)

* unix: fix SIGCHLD waitpid() race in process.c (Ben Noordhuis)

* unix, windows: add uv_fs_event_start/stop functions (Saúl Ibarra Corretgé)

* unix: fix non-synchronized access in signal.c (Ben Noordhuis)

* unix: add atomic-ops.h (Ben Noordhuis)

* unix: add spinlock.h (Ben Noordhuis)

* unix: clean up uv_tty_set_mode() a little (Ben Noordhuis)

* unix: make uv_tty_reset_mode() async signal-safe (Ben Noordhuis)

* include: add E2BIG status code mapping (Ben Noordhuis)

* windows: fix duplicate case build error (Ben Noordhuis)

* windows: remove unneeded check (Saúl Ibarra Corretgé)

* include: document pipe path truncation behavior (Ben Noordhuis)

* fsevents: increase stack size for OSX 10.9 (Fedor Indutny)

* windows: _snprintf expected wrong parameter type in string (Maks Naumov)

* windows: "else" keyword is missing (Maks Naumov)

* windows: incorrect check for SOCKET_ERROR (Maks Naumov)

* windows: add stdlib.h to satisfy reference to abort (Sean Farrell)

* build: fix check target for mingw (Sean Farrell)

* unix: move uv_shutdown() assertion (Keno Fischer)

* darwin: avoid calling GetCurrentProcess (Fedor Indutny)


2013.10.19, Version 0.10.18 (Stable), 9ec52963b585e822e87bdc5de28d6143aff0d2e5

Changes since version 0.10.17:

* unix: fix uv_spawn() NULL pointer deref on ENOMEM (Ben Noordhuis)

* unix: don't close inherited fds on uv_spawn() fail (Ben Noordhuis)

* unix: revert recent FSEvent changes (Ben Noordhuis)

* unix: fix non-synchronized access in signal.c (Ben Noordhuis)


2013.09.25, Version 0.10.17 (Stable), 9670e0a93540c2f0d86c84a375f2303383c11e7e

Changes since version 0.10.16:

* build: remove GCC_WARN_ABOUT_MISSING_NEWLINE (Ben Noordhuis)

* darwin: fix 10.6 build error in fsevents.c (Ben Noordhuis)


2013.09.06, Version 0.10.16 (Stable), 2bce230d81f4853a23662cbeb26fe98010b1084b

Changes since version 0.10.15:

* windows: make uv_shutdown() for write-only pipes work (Bert Belder)

* windows: make uv_fs_open() report EINVAL when invalid arguments are passed
(Bert Belder)

* windows: make uv_fs_open() report _open_osfhandle() failure correctly (Bert
Belder)

* windows: make uv_fs_chmod() report errors correctly (Bert Belder)

* windows: wrap multi-statement macros in do..while block (Bert Belder)


2013.09.05, Version 0.11.13 (Unstable), f5b6db6c1d7f93d28281207fd47c3841c9a9792e

Changes since version 0.11.12:

@@ -113,6 +261,20 @@ Changes since version 0.11.8:
par with libuv's behavior on unix. (Bert Belder)


2013.08.24, Version 0.10.15 (Stable), 221078a8fdd9b853c6b557b3d9a5dd744b4fdd6b

Changes since version 0.10.14:

* fsevents: create FSEvents thread on demand (Ben Noordhuis)

* fsevents: use a single thread for interacting with FSEvents, because it's not
thread-safe. (Fedor Indutny)

* fsevents: share FSEventStream between multiple FS watchers, which removes a
limit on the maximum number of file watchers that can be created on OS X.
(Fedor Indutny)


2013.08.22, Version 0.11.8 (Unstable), a5260462db80ab0deab6b9e6a8991dd8f5a9a2f8

Changes since version 0.11.7:
@@ -164,6 +326,13 @@ Changes since version 0.11.7:
* windows: omit stdint.h, fix msvc 2008 build error (Ben Noordhuis)


2013.08.22, Version 0.10.14 (Stable), 15d64132151c18b26346afa892444b95e2addad0

Changes since version 0.10.13:

* unix: retry waitpid() on EINTR (Ben Noordhuis)


2013.08.07, Version 0.11.7 (Unstable), 3cad361f8776f70941b39d65bd9426bcb1aa817b

Changes since version 0.11.6:
@@ -31,13 +31,17 @@ libuv_la_SOURCES = src/fs-poll.c \
src/uv-common.h \
src/version.c

if SUNOS
libuv_la_CFLAGS += -pthread
endif

if WINNT

include_HEADERS += include/uv-win.h include/tree.h
AM_CPPFLAGS += -I$(top_srcdir)/src/win \
-DWIN32_LEAN_AND_MEAN \
-D_WIN32_WINNT=0x0600
LIBS += -lws2_32 -lpsapi -lphlpapi2
LIBS += -lws2_32 -lpsapi -liphlpapi -lshell32
libuv_la_SOURCES += src/win/async.c \
src/win/atomicops-inl.h \
src/win/core.c \
@@ -76,6 +80,7 @@ else # WINNT
include_HEADERS += include/uv-unix.h
AM_CPPFLAGS += -I$(top_srcdir)/src/unix
libuv_la_SOURCES += src/unix/async.c \
src/unix/atomic-ops.h \
src/unix/core.c \
src/unix/dl.c \
src/unix/fs.c \
@@ -87,6 +92,7 @@ libuv_la_SOURCES += src/unix/async.c \
src/unix/poll.c \
src/unix/process.c \
src/unix/signal.c \
src/unix/spinlock.h \
src/unix/stream.c \
src/unix/tcp.c \
src/unix/thread.c \
@@ -103,8 +109,6 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/dns-server.c \
test/echo-server.c \
test/run-tests.c \
test/runner-unix.c \
test/runner-unix.h \
test/runner.c \
test/runner.h \
test/task.h \
@@ -114,6 +118,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-barrier.c \
test/test-callback-order.c \
test/test-callback-stack.c \
test/test-close-order.c \
test/test-condvar.c \
test/test-connection-fail.c \
test/test-cwd-and-chdir.c \
@@ -192,6 +197,16 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-walk-handles.c
test_run_tests_LDADD = libuv.la

if WINNT
test_run_tests_SOURCES += test/runner-win.c \
test/runner-win.h
else
test_run_tests_SOURCES += test/runner-unix.c \
test/runner-unix.h
endif



if AIX
libuv_la_CFLAGS += -D_ALL_SOURCE -D_XOPEN_SOURCE=500
libuv_la_SOURCES += src/unix/aix.c
@@ -1,37 +1,37 @@
# libuv

libuv is a platform layer for [node.js][]. Its purpose is to abstract IOCP
on Windows and epoll/kqueue/event ports/etc. on Unix systems. We intend to
eventually contain all platform differences in this library.
libuv is a multi-platform support library with a focus on asynchronous I/O. It
was primarily developed for use by [Node.js](http://node.js.org), but it's also
used by Mozilla's [Rust language](http://www.rust-lang.org/),
[Luvit](http://luvit.io/), [Julia](http://julialang.org/),
[pyuv](https://crate.io/packages/pyuv/), and others.

## Features
## Feature highlights

* Non-blocking TCP sockets
* Full-featured event loop backed by epoll, kqueue, IOCP, event ports.

* Non-blocking named pipes
* Asynchronous TCP and UDP sockets

* UDP
* Asynchronous DNS resolution

* Timers
* Asynchronous file and file system operations

* Child process spawning
* File system events

* Asynchronous DNS via `uv_getaddrinfo`.
* ANSI escape code controlled TTY

* Asynchronous file system APIs `uv_fs_*`
* IPC with socket sharing, using Unix domain sockets or named pipes (Windows)

* High resolution time `uv_hrtime`
* Child processes

* Current executable path look up `uv_exepath`
* Thread pool

* Thread pool scheduling `uv_queue_work`
* Signal handling

* ANSI escape code controlled TTY `uv_tty_t`
* High resolution clock

* File system events using inotify, kqueue, event ports,
FSEvents and `ReadDirectoryChangesW`
* Threading and synchronization primitives

* IPC and socket sharing between processes `uv_write2`

## Community

@@ -62,31 +62,40 @@ To build with autotools:
$ make check
$ make install

To build with Visual Studio run the vcbuild.bat file which will
checkout the GYP code into build/gyp and generate the uv.sln and
related files.
### Windows

Windows users can also build from the command line using msbuild.
This is done by running vcbuild.bat from Visual Studio command prompt.
First, Python 2.6 or 2.7 must be installed as it is required by [GYP][].

To have GYP generate build script for another system, make sure that
you have Python 2.6 or 2.7 installed, then checkout GYP into the
Also, the directory for the preferred Python executable must be specified
by the `PYTHON` or `Path` environment variables.

To build with Visual Studio, launch a git shell (e.g. Cmd or PowerShell)
and run vcbuild.bat which will checkout the GYP code into build/gyp and
generate uv.sln as well as related project files.

To have GYP generate build script for another system, checkout GYP into the
project tree manually:

$ mkdir -p build
$ git clone https://git.chromium.org/external/gyp.git build/gyp

Unix users run:
### Unix

Run:

$ ./gyp_uv -f make
$ make -C out

Macintosh users run:
### OS X

Run:

$ ./gyp_uv -f xcode
$ xcodebuild -project uv.xcodeproj -configuration Release -target All

To build for android:
### Android

Run:

$ source ./android-configure NDK_PATH gyp
$ make -C out
@@ -103,7 +112,7 @@ Studio license.

Linux using the GCC toolchain.

MacOS using the GCC or XCode toolchain.
OS X using the GCC or XCode toolchain.

Solaris 121 and later using GCC toolchain.

@@ -172,7 +172,6 @@
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
'PREBINDING': 'NO', # No -Wl,-prebind
'USE_HEADERMAP': 'NO',
'OTHER_CFLAGS': [
@@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

AC_PREREQ(2.57)
AC_INIT([libuv], [0.11.13], [https://github.com/joyent/libuv/issues])
AC_INIT([libuv], [0.11.14], [https://github.com/joyent/libuv/issues])
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects] UV_EXTRA_AUTOMAKE_FLAGS)
@@ -44,322 +44,328 @@
/* Only map to the system errno on non-Windows platforms. It's apparently
* a fairly common practice for Windows programmers to redefine errno codes.
*/
#if defined(E2BIG) && !defined(_WIN32)
# define UV__E2BIG (-E2BIG)
#else
# define UV__E2BIG (-4093)
#endif

#if defined(EACCES) && !defined(_WIN32)
# define UV__EACCES (-EACCES)
#else
# define UV__EACCES (-4093)
# define UV__EACCES (-4092)
#endif

#if defined(EADDRINFO) && !defined(_WIN32)
# define UV__EADDRINFO EADDRINFO
#else
# define UV__EADDRINFO (-4092)
# define UV__EADDRINFO (-4091)
#endif

#if defined(EADDRINUSE) && !defined(_WIN32)
# define UV__EADDRINUSE (-EADDRINUSE)
#else
# define UV__EADDRINUSE (-4092)
# define UV__EADDRINUSE (-4091)
#endif

#if defined(EADDRNOTAVAIL) && !defined(_WIN32)
# define UV__EADDRNOTAVAIL (-EADDRNOTAVAIL)
#else
# define UV__EADDRNOTAVAIL (-4091)
# define UV__EADDRNOTAVAIL (-4090)
#endif

#if defined(EAFNOSUPPORT) && !defined(_WIN32)
# define UV__EAFNOSUPPORT (-EAFNOSUPPORT)
#else
# define UV__EAFNOSUPPORT (-4090)
# define UV__EAFNOSUPPORT (-4089)
#endif

#if defined(EAGAIN) && !defined(_WIN32)
# define UV__EAGAIN (-EAGAIN)
#else
# define UV__EAGAIN (-4089)
# define UV__EAGAIN (-4088)
#endif

#if defined(EALREADY) && !defined(_WIN32)
# define UV__EALREADY (-EALREADY)
#else
# define UV__EALREADY (-4085)
# define UV__EALREADY (-4084)
#endif

#if defined(EBADF) && !defined(_WIN32)
# define UV__EBADF (-EBADF)
#else
# define UV__EBADF (-4084)
# define UV__EBADF (-4083)
#endif

#if defined(EBUSY) && !defined(_WIN32)
# define UV__EBUSY (-EBUSY)
#else
# define UV__EBUSY (-4083)
# define UV__EBUSY (-4082)
#endif

#if defined(ECANCELED) && !defined(_WIN32)
# define UV__ECANCELED (-ECANCELED)
#else
# define UV__ECANCELED (-4082)
# define UV__ECANCELED (-4081)
#endif

#if defined(ECHARSET) && !defined(_WIN32)
# define UV__ECHARSET (-ECHARSET)
#else
# define UV__ECHARSET (-4081)
# define UV__ECHARSET (-4080)
#endif

#if defined(ECONNABORTED) && !defined(_WIN32)
# define UV__ECONNABORTED (-ECONNABORTED)
#else
# define UV__ECONNABORTED (-4080)
# define UV__ECONNABORTED (-4079)
#endif

#if defined(ECONNREFUSED) && !defined(_WIN32)
# define UV__ECONNREFUSED (-ECONNREFUSED)
#else
# define UV__ECONNREFUSED (-4079)
# define UV__ECONNREFUSED (-4078)
#endif

#if defined(ECONNRESET) && !defined(_WIN32)
# define UV__ECONNRESET (-ECONNRESET)
#else
# define UV__ECONNRESET (-4078)
# define UV__ECONNRESET (-4077)
#endif

#if defined(EDESTADDRREQ) && !defined(_WIN32)
# define UV__EDESTADDRREQ (-EDESTADDRREQ)
#else
# define UV__EDESTADDRREQ (-4077)
# define UV__EDESTADDRREQ (-4076)
#endif

#if defined(EEXIST) && !defined(_WIN32)
# define UV__EEXIST (-EEXIST)
#else
# define UV__EEXIST (-4076)
# define UV__EEXIST (-4075)
#endif

#if defined(EFAULT) && !defined(_WIN32)
# define UV__EFAULT (-EFAULT)
#else
# define UV__EFAULT (-4075)
# define UV__EFAULT (-4074)
#endif

#if defined(EHOSTUNREACH) && !defined(_WIN32)
# define UV__EHOSTUNREACH (-EHOSTUNREACH)
#else
# define UV__EHOSTUNREACH (-4074)
# define UV__EHOSTUNREACH (-4073)
#endif

#if defined(EINTR) && !defined(_WIN32)
# define UV__EINTR (-EINTR)
#else
# define UV__EINTR (-4073)
# define UV__EINTR (-4072)
#endif

#if defined(EINVAL) && !defined(_WIN32)
# define UV__EINVAL (-EINVAL)
#else
# define UV__EINVAL (-4072)
# define UV__EINVAL (-4071)
#endif

#if defined(EIO) && !defined(_WIN32)
# define UV__EIO (-EIO)
#else
# define UV__EIO (-4071)
# define UV__EIO (-4070)
#endif

#if defined(EISCONN) && !defined(_WIN32)
# define UV__EISCONN (-EISCONN)
#else
# define UV__EISCONN (-4070)
# define UV__EISCONN (-4069)
#endif

#if defined(EISDIR) && !defined(_WIN32)
# define UV__EISDIR (-EISDIR)
#else
# define UV__EISDIR (-4069)
# define UV__EISDIR (-4068)
#endif

#if defined(ELOOP) && !defined(_WIN32)
# define UV__ELOOP (-ELOOP)
#else
# define UV__ELOOP (-4068)
# define UV__ELOOP (-4067)
#endif

#if defined(EMFILE) && !defined(_WIN32)
# define UV__EMFILE (-EMFILE)
#else
# define UV__EMFILE (-4067)
# define UV__EMFILE (-4066)
#endif

#if defined(EMSGSIZE) && !defined(_WIN32)
# define UV__EMSGSIZE (-EMSGSIZE)
#else
# define UV__EMSGSIZE (-4066)
# define UV__EMSGSIZE (-4065)
#endif

#if defined(ENAMETOOLONG) && !defined(_WIN32)
# define UV__ENAMETOOLONG (-ENAMETOOLONG)
#else
# define UV__ENAMETOOLONG (-4065)
# define UV__ENAMETOOLONG (-4064)
#endif

#if defined(ENETDOWN) && !defined(_WIN32)
# define UV__ENETDOWN (-ENETDOWN)
#else
# define UV__ENETDOWN (-4064)
# define UV__ENETDOWN (-4063)
#endif

#if defined(ENETUNREACH) && !defined(_WIN32)
# define UV__ENETUNREACH (-ENETUNREACH)
#else
# define UV__ENETUNREACH (-4063)
# define UV__ENETUNREACH (-4062)
#endif

#if defined(ENFILE) && !defined(_WIN32)
# define UV__ENFILE (-ENFILE)
#else
# define UV__ENFILE (-4062)
# define UV__ENFILE (-4061)
#endif

#if defined(ENOBUFS) && !defined(_WIN32)
# define UV__ENOBUFS (-ENOBUFS)
#else
# define UV__ENOBUFS (-4061)
# define UV__ENOBUFS (-4060)
#endif

#if defined(ENODEV) && !defined(_WIN32)
# define UV__ENODEV (-ENODEV)
#else
# define UV__ENODEV (-4060)
# define UV__ENODEV (-4059)
#endif

#if defined(ENOENT) && !defined(_WIN32)
# define UV__ENOENT (-ENOENT)
#else
# define UV__ENOENT (-4059)
# define UV__ENOENT (-4058)
#endif

#if defined(ENOMEM) && !defined(_WIN32)
# define UV__ENOMEM (-ENOMEM)
#else
# define UV__ENOMEM (-4058)
# define UV__ENOMEM (-4057)
#endif

#if defined(ENONET) && !defined(_WIN32)
# define UV__ENONET (-ENONET)
#else
# define UV__ENONET (-4057)
# define UV__ENONET (-4056)
#endif

#if defined(ENOSPC) && !defined(_WIN32)
# define UV__ENOSPC (-ENOSPC)
#else
# define UV__ENOSPC (-4056)
# define UV__ENOSPC (-4055)
#endif

#if defined(ENOSYS) && !defined(_WIN32)
# define UV__ENOSYS (-ENOSYS)
#else
# define UV__ENOSYS (-4055)
# define UV__ENOSYS (-4054)
#endif

#if defined(ENOTCONN) && !defined(_WIN32)
# define UV__ENOTCONN (-ENOTCONN)
#else
# define UV__ENOTCONN (-4054)
# define UV__ENOTCONN (-4053)
#endif

#if defined(ENOTDIR) && !defined(_WIN32)
# define UV__ENOTDIR (-ENOTDIR)
#else
# define UV__ENOTDIR (-4053)
# define UV__ENOTDIR (-4052)
#endif

#if defined(ENOTEMPTY) && !defined(_WIN32)
# define UV__ENOTEMPTY (-ENOTEMPTY)
#else
# define UV__ENOTEMPTY (-4052)
# define UV__ENOTEMPTY (-4051)
#endif

#if defined(ENOTSOCK) && !defined(_WIN32)
# define UV__ENOTSOCK (-ENOTSOCK)
#else
# define UV__ENOTSOCK (-4051)
# define UV__ENOTSOCK (-4050)
#endif

#if defined(ENOTSUP) && !defined(_WIN32)
# define UV__ENOTSUP (-ENOTSUP)
#else
# define UV__ENOTSUP (-4050)
# define UV__ENOTSUP (-4049)
#endif

#if defined(EPERM) && !defined(_WIN32)
# define UV__EPERM (-EPERM)
#else
# define UV__EPERM (-4049)
# define UV__EPERM (-4048)
#endif

#if defined(EPIPE) && !defined(_WIN32)
# define UV__EPIPE (-EPIPE)
#else
# define UV__EPIPE (-4048)
# define UV__EPIPE (-4047)
#endif

#if defined(EPROTO) && !defined(_WIN32)
# define UV__EPROTO (-EPROTO)
#else
# define UV__EPROTO (-4047)
# define UV__EPROTO (-4046)
#endif

#if defined(EPROTONOSUPPORT) && !defined(_WIN32)
# define UV__EPROTONOSUPPORT (-EPROTONOSUPPORT)
#else
# define UV__EPROTONOSUPPORT (-4046)
# define UV__EPROTONOSUPPORT (-4045)
#endif

#if defined(EPROTOTYPE) && !defined(_WIN32)
# define UV__EPROTOTYPE (-EPROTOTYPE)
#else
# define UV__EPROTOTYPE (-4045)
# define UV__EPROTOTYPE (-4044)
#endif

#if defined(EROFS) && !defined(_WIN32)
# define UV__EROFS (-EROFS)
#else
# define UV__EROFS (-4044)
# define UV__EROFS (-4043)
#endif

#if defined(ESHUTDOWN) && !defined(_WIN32)
# define UV__ESHUTDOWN (-ESHUTDOWN)
#else
# define UV__ESHUTDOWN (-4043)
# define UV__ESHUTDOWN (-4042)
#endif

#if defined(ESPIPE) && !defined(_WIN32)
# define UV__ESPIPE (-ESPIPE)
#else
# define UV__ESPIPE (-4042)
# define UV__ESPIPE (-4041)
#endif

#if defined(ESRCH) && !defined(_WIN32)
# define UV__ESRCH (-ESRCH)
#else
# define UV__ESRCH (-4041)
# define UV__ESRCH (-4040)
#endif

#if defined(ETIMEDOUT) && !defined(_WIN32)
# define UV__ETIMEDOUT (-ETIMEDOUT)
#else
# define UV__ETIMEDOUT (-4040)
# define UV__ETIMEDOUT (-4039)
#endif

#if defined(EXDEV) && !defined(_WIN32)
# define UV__EXDEV (-EXDEV)
#else
# define UV__EXDEV (-4038)
# define UV__EXDEV (-4037)
#endif

#endif /* UV_ERRNO_H_ */
@@ -59,9 +59,6 @@
# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */
#endif

#define UV_IO_PRIVATE_FIELDS \
UV_IO_PRIVATE_PLATFORM_FIELDS \

struct uv__io_s;
struct uv__async;
struct uv_loop_s;
@@ -78,7 +75,7 @@ struct uv__io_s {
unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
unsigned int events; /* Current event mask. */
int fd;
UV_IO_PRIVATE_FIELDS
UV_IO_PRIVATE_PLATFORM_FIELDS
};

typedef void (*uv__async_cb)(struct uv_loop_s* loop,
@@ -291,6 +288,7 @@ typedef struct {
#define UV_PROCESS_PRIVATE_FIELDS \
void* queue[2]; \
int errorno; \
int status; \

#define UV_FS_PRIVATE_FIELDS \
const char *new_path; \
@@ -46,28 +46,23 @@ extern "C" {
#endif

#include "uv-errno.h"
#include <stddef.h>

#if defined(_MSC_VER) && _MSC_VER < 1600
# include "stdint-msvc2008.h"
#else
# include <stdint.h>
#endif

#include <sys/types.h> /* size_t */

#if defined(__SVR4) && !defined(__unix__)
# define __unix__
#endif

#if defined(__unix__) || defined(__POSIX__) || \
defined(__APPLE__) || defined(_AIX)
# include "uv-unix.h"
#else
#if defined(_WIN32)
# include "uv-win.h"
#else
# include "uv-unix.h"
#endif

/* Expand this list if necessary. */
#define UV_ERRNO_MAP(XX) \
XX(E2BIG, "argument list too long") \
XX(EACCES, "permission denied") \
XX(EADDRINUSE, "address already in use") \
XX(EADDRNOTAVAIL, "address not available") \
@@ -310,7 +305,7 @@ UV_EXTERN void uv_update_time(uv_loop_t*);
* Don't make assumptions about the starting point, you will only get
* disappointed.
*
* Use uv_hrtime() if you need sub-milliseond granularity.
* Use uv_hrtime() if you need sub-millisecond granularity.
*/
UV_EXTERN uint64_t uv_now(uv_loop_t*);

@@ -522,8 +517,24 @@ UV_EXTERN size_t uv_handle_size(uv_handle_type type);
UV_EXTERN size_t uv_req_size(uv_req_type type);

/*
* Returns 1 if the prepare/check/idle/timer handle has been started, 0
* otherwise. For other handle types this always returns 1.
* Returns non-zero if the handle is active, zero if it's inactive.
*
* What "active" means depends on the type of handle:
*
* - A uv_async_t handle is always active and cannot be deactivated, except
* by closing it with uv_close().
*
* - A uv_pipe_t, uv_tcp_t, uv_udp_t, etc. handle - basically any handle that
* deals with I/O - is active when it is doing something that involves I/O,
* like reading, writing, connecting, accepting new connections, etc.
*
* - A uv_check_t, uv_idle_t, uv_timer_t, etc. handle is active when it has
* been started with a call to uv_check_start(), uv_idle_start(), etc.
*
* Rule of thumb: if a handle of type uv_foo_t has a uv_foo_start()
* function, then it's active from the moment that function is called.
* Likewise, uv_foo_stop() deactivates the handle again.
*
*/
UV_EXTERN int uv_is_active(const uv_handle_t* handle);

@@ -769,6 +780,12 @@ UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
/*
* Bind the handle to an address and port. `addr` should point to an
* initialized struct sockaddr_in or struct sockaddr_in6.
*
* When the port is already taken, you can expect to see an UV_EADDRINUSE
* error from either uv_tcp_bind(), uv_listen() or uv_tcp_connect().
*
* That is, a successful call to uv_tcp_bind() does not guarantee that
* the call to uv_listen() or uv_tcp_connect() will succeed as well.
*/
UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr);

@@ -1058,8 +1075,11 @@ UV_EXTERN int uv_tty_set_mode(uv_tty_t*, int mode);
/*
* To be called when the program exits. Resets TTY settings to default
* values for the next process to take over.
*
* This function is async signal-safe on UNIX platforms but can fail with error
* code UV_EBUSY if you call it when execution is inside uv_tty_set_mode().
*/
UV_EXTERN void uv_tty_reset_mode(void);
UV_EXTERN int uv_tty_reset_mode(void);

/*
* Gets the current Window size. On success zero is returned.
@@ -1098,8 +1118,20 @@ UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
*/
UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file);

/*
* Bind the pipe to a file path (UNIX) or a name (Windows.)
*
* Paths on UNIX get truncated to `sizeof(sockaddr_un.sun_path)` bytes,
* typically between 92 and 108 bytes.
*/
UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);

/*
* Connect to the UNIX domain socket or the named pipe.
*
* Paths on UNIX get truncated to `sizeof(sockaddr_un.sun_path)` bytes,
* typically between 92 and 108 bytes.
*/
UV_EXTERN void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
const char* name, uv_connect_cb cb);

@@ -1398,7 +1430,7 @@ typedef struct uv_process_options_s {
* If non-null this represents a directory the subprocess should execute
* in. Stands for current working directory.
*/
char* cwd;
const char* cwd;
/*
* Various flags that control how uv_spawn() behaves. See the definition of
* `enum uv_process_flags` below.
@@ -1831,7 +1863,7 @@ UV_EXTERN void uv_loadavg(double avg[3]);


/*
* Flags to be passed to uv_fs_event_init.
* Flags to be passed to uv_fs_event_start.
*/
enum uv_fs_event_flags {
/*
@@ -1861,8 +1893,15 @@ enum uv_fs_event_flags {
};


UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
const char* filename, uv_fs_event_cb cb, int flags);
UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle);

UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle,
uv_fs_event_cb cb,
const char* filename,
unsigned int flags);

UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle);


/* Utility */

@@ -85,7 +85,7 @@ int uv_exepath(char* buffer, size_t* size) {
return fd;

res = read(fd, &ps, sizeof(ps));
close(fd);
uv__close(fd);
if (res < 0)
return res;

@@ -128,12 +128,20 @@ void uv_loadavg(double avg[3]) {
}


int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb,
int flags) {
loop->counters.fs_event_init++;
int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
return -ENOSYS;
}


int uv_fs_event_start(uv_fs_event_t* handle,
uv_fs_event_cb cb,
const char* filename,
unsigned int flags) {
return -ENOSYS;
}


int uv_fs_event_stop(uv_fs_event_t* handle) {
return -ENOSYS;
}

@@ -179,7 +187,7 @@ int uv_resident_set_memory(size_t* rss) {
*rss = (size_t)psinfo.pr_rssize * 1024;
err = 0;
}
close(fd);
uv__close(fd);

return err;
}
@@ -291,14 +299,14 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
}

if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) {
close(sockfd);
uv__close(sockfd);
return -ENOSYS;
}

ifc.ifc_req = (struct ifreq*)malloc(size);
ifc.ifc_len = size;
if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
close(sockfd);
uv__close(sockfd);
return -ENOSYS;
}

@@ -317,7 +325,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses,

memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
close(sockfd);
uv__close(sockfd);
return -ENOSYS;
}

@@ -331,7 +339,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
*addresses = (uv_interface_address_t*)
malloc(*count * sizeof(uv_interface_address_t));
if (!(*addresses)) {
close(sockfd);
uv__close(sockfd);
return -ENOMEM;
}
address = *addresses;
@@ -348,7 +356,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses,

memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
close(sockfd);
uv__close(sockfd);
return -ENOSYS;
}

@@ -374,7 +382,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses,

#undef ADDR_SIZE

close(sockfd);
uv__close(sockfd);
return 0;
}

@@ -237,11 +237,11 @@ void uv__async_stop(uv_loop_t* loop, struct uv__async* wa) {
return;

uv__io_stop(loop, &wa->io_watcher, UV__POLLIN);
close(wa->io_watcher.fd);
uv__close(wa->io_watcher.fd);
wa->io_watcher.fd = -1;

if (wa->wfd != -1) {
close(wa->wfd);
uv__close(wa->wfd);
wa->wfd = -1;
}
}
@@ -0,0 +1,60 @@
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef UV_ATOMIC_OPS_H_
#define UV_ATOMIC_OPS_H_

#include "internal.h" /* UV_UNUSED */

UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval));
UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval));
UV_UNUSED(static void cpu_relax(void));

/* Prefer hand-rolled assembly over the gcc builtins because the latter also
* issue full memory barriers.
*/
UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
#if defined(__i386__) || defined(__x86_64__)
int out;
__asm__ __volatile__ ("lock; cmpxchg %2, %1;"
: "=a" (out), "+m" (*(volatile int*) ptr)
: "r" (newval), "0" (oldval)
: "memory");
return out;
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif
}

UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) {
#if defined(__i386__) || defined(__x86_64__)
long out;
__asm__ __volatile__ ("lock; cmpxchg %2, %1;"
: "=a" (out), "+m" (*(volatile long*) ptr)
: "r" (newval), "0" (oldval)
: "memory");
return out;
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif
}

UV_UNUSED(static void cpu_relax(void)) {
#if defined(__i386__) || defined(__x86_64__)
__asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */
#endif
}

#endif /* UV_ATOMIC_OPS_H_ */
@@ -340,7 +340,7 @@ int uv__socket(int domain, int type, int protocol) {
err = uv__cloexec(sockfd, 1);

if (err) {
close(sockfd);
uv__close(sockfd);
return err;
}

@@ -397,7 +397,7 @@ int uv__accept(int sockfd) {
err = uv__nonblock(peerfd, 1);

if (err) {
close(peerfd);
uv__close(peerfd);
return err;
}

@@ -406,6 +406,26 @@ int uv__accept(int sockfd) {
}


int uv__close(int fd) {
int saved_errno;
int rc;

assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */
assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */

saved_errno = errno;
rc = close(fd);
if (rc == -1) {
rc = -errno;
if (rc == -EINTR)
rc = -EINPROGRESS; /* For platform/libc consistency. */
errno = saved_errno;
}

return rc;
}


#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)

int uv__nonblock(int fd, int set) {
@@ -514,7 +534,7 @@ int uv__dup(int fd) {

err = uv__cloexec(fd, 1);
if (err) {
close(fd);
uv__close(fd);
return err;
}

@@ -61,7 +61,6 @@ int uv__set_process_title(const char* title) {
CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef);
void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef);
void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef);
OSErr (*pGetCurrentProcess)(ProcessSerialNumber*);
CFTypeRef (*pLSGetCurrentApplicationASN)(void);
OSStatus (*pLSSetApplicationInformationItem)(int,
CFTypeRef,
@@ -72,7 +71,13 @@ int uv__set_process_title(const char* title) {
void* core_foundation_handle;
CFBundleRef launch_services_bundle;
CFStringRef* display_name_key;
ProcessSerialNumber psn;
CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
CFBundleRef (*pCFBundleGetMainBundle)(void);
CFBundleRef hi_services_bundle;
OSStatus (*pSetApplicationIsDaemon)(int);
CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
void*);
CFTypeRef asn;
int err;

@@ -89,8 +94,6 @@ int uv__set_process_title(const char* title) {
if (application_services_handle == NULL || core_foundation_handle == NULL)
goto out;

pGetCurrentProcess =
dlsym(application_services_handle, "GetCurrentProcess");
pCFStringCreateWithCString =
dlsym(core_foundation_handle, "CFStringCreateWithCString");
pCFBundleGetBundleWithIdentifier =
@@ -100,8 +103,7 @@ int uv__set_process_title(const char* title) {
pCFBundleGetFunctionPointerForName =
dlsym(core_foundation_handle, "CFBundleGetFunctionPointerForName");

if (pGetCurrentProcess == NULL ||
pCFStringCreateWithCString == NULL ||
if (pCFStringCreateWithCString == NULL ||
pCFBundleGetBundleWithIdentifier == NULL ||
pCFBundleGetDataPointerForName == NULL ||
pCFBundleGetFunctionPointerForName == NULL) {
@@ -136,8 +138,44 @@ int uv__set_process_title(const char* title) {
if (display_name_key == NULL || *display_name_key == NULL)
goto out;

/* Force the process manager to initialize. */
pGetCurrentProcess(&psn);
pCFBundleGetInfoDictionary = dlsym(core_foundation_handle,
"CFBundleGetInfoDictionary");
pCFBundleGetMainBundle = dlsym(core_foundation_handle,
"CFBundleGetMainBundle");
if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL)
goto out;

/* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */
hi_services_bundle =
pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices"));
err = -ENOENT;
if (hi_services_bundle == NULL)
goto out;

pSetApplicationIsDaemon = pCFBundleGetFunctionPointerForName(
hi_services_bundle,
S("SetApplicationIsDaemon"));
pLSApplicationCheckIn = pCFBundleGetFunctionPointerForName(
launch_services_bundle,
S("_LSApplicationCheckIn"));
pLSSetApplicationLaunchServicesServerConnectionStatus =
pCFBundleGetFunctionPointerForName(
launch_services_bundle,
S("_LSSetApplicationLaunchServicesServerConnectionStatus"));
if (pSetApplicationIsDaemon == NULL ||
pLSApplicationCheckIn == NULL ||
pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) {
goto out;
}

if (pSetApplicationIsDaemon(1) != noErr)
goto out;

pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);

/* Check into process manager?! */
pLSApplicationCheckIn(-2,
pCFBundleGetInfoDictionary(pCFBundleGetMainBundle()));

asn = pLSGetCurrentApplicationASN();

@@ -273,7 +273,9 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
return -errno;
}

/* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of ncpu */
/* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of
* ncpu.
*/
size = sizeof(maxcpus);
if (sysctlbyname(maxcpus_key, &maxcpus, &size, NULL, 0)) {
SAVE_ERRNO(free(*cpu_infos));
@@ -76,7 +76,7 @@ typedef struct uv__cf_loop_state_s uv__cf_loop_state_t;
struct uv__cf_loop_state_s {
CFRunLoopRef loop;
CFRunLoopSourceRef signal_source;
volatile int fsevent_need_reschedule;
int fsevent_need_reschedule;
FSEventStreamRef fsevent_stream;
uv_sem_t fsevent_sem;
uv_mutex_t fsevent_mutex;
@@ -360,9 +360,13 @@ static void uv__fsevents_reschedule(uv_fs_event_t* handle) {
/* Optimization to prevent O(n^2) time spent when starting to watch
* many files simultaneously
*/
if (!state->fsevent_need_reschedule)
return;
uv_mutex_lock(&state->fsevent_mutex);
if (state->fsevent_need_reschedule == 0) {
uv_mutex_unlock(&state->fsevent_mutex);
goto final;
}
state->fsevent_need_reschedule = 0;
uv_mutex_unlock(&state->fsevent_mutex);

/* Destroy previous FSEventStream */
uv__fsevents_destroy_stream(handle->loop);
@@ -399,13 +403,14 @@ static void uv__fsevents_reschedule(uv_fs_event_t* handle) {
uv__fsevents_create_stream(handle->loop, cf_paths);
}

final:
/*
* Main thread will block until the removal of handle from the list,
* we must tell it when we're ready.
*
* NOTE: This is coupled with `uv_sem_wait()` in `uv__fsevents_close`
*/
if (uv__is_closing(handle))
if (!uv__is_active(handle))
uv_sem_post(&state->fsevent_sem);
}

@@ -547,7 +552,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) {
attr = NULL;

if (attr != NULL)
if (pthread_attr_setstacksize(attr, 3 * PTHREAD_STACK_MIN))
if (pthread_attr_setstacksize(attr, 4 * PTHREAD_STACK_MIN))
abort();

loop->cf_state = state;
@@ -130,6 +130,7 @@ enum {

/* core */
int uv__nonblock(int fd, int set);
int uv__close(int fd);
int uv__cloexec(int fd, int set);
int uv__socket(int domain, int type, int protocol);
int uv__dup(int fd);