diff options
author | isaacs <i@izs.me> | 2012-02-01 06:18:00 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-02-01 06:18:00 +0400 |
commit | 18d179c2d8f916c07a763ea8e99ed6dc77751bfa (patch) | |
tree | d2066d272d5e81f21c355e0ab9b6432dcebd3c5f /lib | |
parent | 33b7fc250f061af42b595decf6c0edf360c5aae9 (diff) | |
parent | 7e0bf7d57de318f45a097e05644efa49beb65209 (diff) |
Merge remote-tracking branch 'ry/v0.6' into master
Conflicts:
ChangeLog
deps/uv/src/unix/udp.c
deps/uv/src/win/fs.c
deps/uv/src/win/udp.c
deps/uv/test/test-fs.c
doc/index.html
doc/logos/index.html
doc/template.html
src/node_version.h
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dgram.js | 40 | ||||
-rw-r--r-- | lib/http.js | 6 | ||||
-rw-r--r-- | lib/module.js | 23 | ||||
-rw-r--r-- | lib/timers.js | 16 |
4 files changed, 60 insertions, 25 deletions
diff --git a/lib/dgram.js b/lib/dgram.js index d5c2e0da69c..b5b0473de83 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -223,30 +223,46 @@ Socket.prototype.address = function() { Socket.prototype.setBroadcast = function(arg) { - if (this._handle.setBroadcast((arg) ? 1 : 0) == -1) { - throw errnoException(errno, 'setBroadcast'); + if (this._handle.setBroadcast((arg) ? 1 : 0)) { + throw errnoException(errno, 'setBroadcast'); } - - return true; }; Socket.prototype.setTTL = function(arg) { - throw new Error('not yet implemented'); + if (typeof arg !== 'number') { + throw new TypeError('Argument must be a number'); + } + + if (this._handle.setTTL(arg)) { + throw errnoException(errno, 'setTTL'); + } + + return arg; }; Socket.prototype.setMulticastTTL = function(arg) { - if (this._handle.setMulticastTTL(arg) == -1) { + if (typeof arg !== 'number') { + throw new TypeError('Argument must be a number'); + } + + if (this._handle.setMulticastTTL(arg)) { throw errnoException(errno, 'setMulticastTTL'); } - return true; + return arg; }; Socket.prototype.setMulticastLoopback = function(arg) { - throw new Error('not yet implemented'); + arg = arg ? 1 : 0; + + if (this._handle.setMulticastLoopback(arg)) { + throw errnoException(errno, 'setMulticastLoopback'); + } + + return arg; // 0.4 compatibility }; @@ -258,7 +274,9 @@ Socket.prototype.addMembership = function(multicastAddress, throw new Error('multicast address must be specified'); } - return this._handle.addMembership(multicastAddress, interfaceAddress); + if (this._handle.addMembership(multicastAddress, interfaceAddress)) { + throw new errnoException(errno, 'addMembership'); + } }; @@ -270,7 +288,9 @@ Socket.prototype.dropMembership = function(multicastAddress, throw new Error('multicast address must be specified'); } - return this._handle.dropMembership(multicastAddress, interfaceAddress); + if (this._handle.dropMembership(multicastAddress, interfaceAddress)) { + throw new errnoException(errno, 'dropMembership'); + } }; diff --git a/lib/http.js b/lib/http.js index f41b94d45c2..f2fea5d5405 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1238,7 +1238,11 @@ ClientRequest.prototype.onSocket = function(socket) { socket.destroy(); } freeParser(); - } else if (parser.incoming && parser.incoming.complete) { + } else if (parser.incoming && parser.incoming.complete && + // When the status code is 100 (Continue), the server will + // send a final response after this client sends a request + // body. So, we must not free the parser. + parser.incoming.statusCode !== 100) { freeParser(); } }; diff --git a/lib/module.js b/lib/module.js index b0ce0d2e3fe..499530e4ded 100644 --- a/lib/module.js +++ b/lib/module.js @@ -276,18 +276,16 @@ Module._load = function(request, parent, isMain) { debug('Module._load REQUEST ' + (request) + ' parent: ' + parent.id); } - var resolved = Module._resolveFilename(request, parent); - var id = resolved[0]; - var filename = resolved[1]; + var filename = Module._resolveFilename(request, parent); var cachedModule = Module._cache[filename]; if (cachedModule) { return cachedModule.exports; } - if (NativeModule.exists(id)) { + if (NativeModule.exists(filename)) { // REPL is a special case, because it needs the real require. - if (id == 'repl') { + if (filename == 'repl') { var replModule = new Module('repl'); replModule._compile(NativeModule.getSource('repl'), 'repl.js'); NativeModule._cache.repl = replModule; @@ -295,10 +293,10 @@ Module._load = function(request, parent, isMain) { } debug('load native module ' + request); - return NativeModule.require(id); + return NativeModule.require(filename); } - var module = new Module(id, parent); + var module = new Module(filename, parent); if (isMain) { process.mainModule = module; @@ -318,7 +316,7 @@ Module._load = function(request, parent, isMain) { Module._resolveFilename = function(request, parent) { if (NativeModule.exists(request)) { - return [request, request]; + return request; } var resolvedModule = Module._resolveLookupPaths(request, parent); @@ -335,8 +333,7 @@ Module._resolveFilename = function(request, parent) { err.code = 'MODULE_NOT_FOUND'; throw err; } - id = filename; - return [id, filename]; + return filename; }; @@ -376,7 +373,7 @@ Module.prototype._compile = function(content, filename) { } require.resolve = function(request) { - return Module._resolveFilename(request, self)[1]; + return Module._resolveFilename(request, self); }; Object.defineProperty(require, 'paths', { get: function() { @@ -472,11 +469,11 @@ Module._extensions['.json'] = function(module, filename) { }; -//Native extension for .node +//Native extension for .node and OS-specific equivalents Module._extensions['.node'] = function(module, filename) { process.dlopen(filename, module.exports); }; - +Module._extensions['.dylib'] = Module._extensions['.node']; // bootstrap main module. Module.runMain = function() { diff --git a/lib/timers.js b/lib/timers.js index 7a57d342776..c5592bf0a20 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -81,7 +81,21 @@ function insert(item, msecs) { } else { L.remove(first); assert(first !== L.peek(list)); - if (first._onTimeout) first._onTimeout(); + + if (!first._onTimeout) continue; + + // v0.4 compatibility: if the timer callback throws and the user's + // uncaughtException handler ignores the exception, other timers that + // expire on this tick should still run. If #2582 goes through, this + // hack should be removed. + // + // https://github.com/joyent/node/issues/2631 + try { + first._onTimeout(); + } catch (e) { + if (!process.listeners('uncaughtException').length) throw e; + process.emit('uncaughtException', e); + } } } |