Permalink
Browse files

Rename `errno` global to `__errno`.

Naming it `errno` was a mistake, the risk of name clashes with user code is too
high.
  • Loading branch information...
1 parent b174dcf commit 53e5c67c72c25b8923d798fa96a910347478e7b2 @bnoordhuis committed Jan 8, 2012
Showing with 30 additions and 32 deletions.
  1. +2 −2 lib/child_process.js
  2. +4 −4 lib/dgram.js
  3. +4 −4 lib/dns.js
  4. +2 −2 lib/fs.js
  5. +11 −11 lib/net.js
  6. +1 −1 src/cares_wrap.cc
  7. +1 −3 src/node.cc
  8. +1 −1 src/node.js
  9. +2 −2 test/common.js
  10. +2 −2 test/simple/test-tcp-wrap.js
View
@@ -133,7 +133,7 @@ function setupChannel(target, channel) {
var writeReq = channel.write(buffer, 0, buffer.length, sendHandle);
if (!writeReq) {
- throw new Error(errno + 'cannot write to IPC channel.');
+ throw new Error(__errno + 'cannot write to IPC channel.');
}
writeReq.oncomplete = nop;
@@ -443,7 +443,7 @@ ChildProcess.prototype.spawn = function(options) {
this._internal.close();
this._internal = null;
- throw errnoException(errno, 'spawn');
+ throw errnoException(__errno, 'spawn');
}
this.pid = this._internal.pid;
View
@@ -121,7 +121,7 @@ Socket.prototype.bind = function(port, address) {
self._handle.lookup(address, function(err, ip) {
if (!err) {
if (self._handle.bind(ip, port || 0, /*flags=*/0)) {
- err = errnoException(errno, 'bind');
+ err = errnoException(__errno, 'bind');
}
else {
self._bound = true;
@@ -184,7 +184,7 @@ Socket.prototype.send = function(buffer,
}
else {
// don't emit as error, dgram_legacy.js compatibility
- callback(errnoException(errno, 'send'));
+ callback(errnoException(__errno, 'send'));
}
}
});
@@ -217,7 +217,7 @@ Socket.prototype.address = function() {
var address = this._handle.getsockname();
if (!address)
- throw errnoException(errno, 'getsockname');
+ throw errnoException(__errno, 'getsockname');
return address;
};
@@ -301,7 +301,7 @@ function onMessage(handle, nread, buf, rinfo) {
var self = handle.socket;
if (nread == -1) {
- self.emit('error', errnoException(errno, 'recvmsg'));
+ self.emit('error', errnoException(__errno, 'recvmsg'));
}
else {
rinfo.size = buf.length; // compatibility
View
@@ -128,14 +128,14 @@ exports.lookup = function(domain, family, callback) {
callback(null, addresses[0], addresses[0].indexOf(':') >= 0 ? 6 : 4);
}
} else {
- callback(errnoException(errno, 'getaddrinfo'));
+ callback(errnoException(__errno, 'getaddrinfo'));
}
}
var wrap = cares.getaddrinfo(domain, family);
if (!wrap) {
- throw errnoException(errno, 'getaddrinfo');
+ throw errnoException(__errno, 'getaddrinfo');
}
wrap.oncomplete = onanswer;
@@ -153,14 +153,14 @@ function resolver(bindingName) {
if (!status) {
callback(null, result);
} else {
- callback(errnoException(errno, bindingName));
+ callback(errnoException(__errno, bindingName));
}
}
callback = makeAsync(callback);
var wrap = binding(name, onanswer);
if (!wrap) {
- throw errnoException(errno, bindingName);
+ throw errnoException(__errno, bindingName);
}
callback.immediately = true;
View
@@ -637,7 +637,7 @@ function FSWatcher() {
this._handle.onchange = function(status, event, filename) {
if (status) {
- self.emit('error', errnoException(errno, 'watch'));
+ self.emit('error', errnoException(__errno, 'watch'));
} else {
self.emit('change', event, filename);
}
@@ -650,7 +650,7 @@ FSWatcher.prototype.start = function(filename, persistent) {
if (r) {
this._handle.close();
- throw errnoException(errno, 'watch');
+ throw errnoException(__errno, 'watch');
}
};
View
@@ -245,7 +245,7 @@ Socket.prototype.end = function(data, encoding) {
var shutdownReq = this._handle.shutdown();
if (!shutdownReq) {
- this.destroy(errnoException(errno, 'shutdown'));
+ this.destroy(errnoException(__errno, 'shutdown'));
return false;
}
@@ -354,7 +354,7 @@ function onread(buffer, offset, length) {
// Optimization: emit the original buffer with end points
if (self.ondata) self.ondata(buffer, offset, end);
- } else if (errno == 'EOF') {
+ } else if (__errno == 'EOF') {
// EOF
self.readable = false;
@@ -370,10 +370,10 @@ function onread(buffer, offset, length) {
if (self.onend) self.onend();
} else {
// Error
- if (errno == 'ECONNRESET') {
+ if (__errno == 'ECONNRESET') {
self.destroy();
} else {
- self.destroy(errnoException(errno, 'read'));
+ self.destroy(errnoException(__errno, 'read'));
}
}
}
@@ -455,7 +455,7 @@ Socket.prototype._write = function(data, encoding, cb) {
var writeReq = this._handle.write(data);
if (!writeReq) {
- this.destroy(errnoException(errno, 'write'));
+ this.destroy(errnoException(__errno, 'write'));
return false;
}
@@ -476,7 +476,7 @@ function afterWrite(status, handle, req, buffer) {
}
if (status) {
- self.destroy(errnoException(errno, 'write'));
+ self.destroy(errnoException(__errno, 'write'));
return;
}
@@ -521,7 +521,7 @@ function connect(self, address, port, addressType) {
if (connectReq !== null) {
connectReq.oncomplete = afterConnect;
} else {
- self.destroy(errnoException(errno, 'connect'));
+ self.destroy(errnoException(__errno, 'connect'));
}
}
@@ -629,7 +629,7 @@ function afterConnect(status, handle, req) {
}
} else {
self._connectQueueCleanUp();
- self.destroy(errnoException(errno, 'connect'));
+ self.destroy(errnoException(__errno, 'connect'));
}
}
@@ -711,7 +711,7 @@ Server.prototype._listen2 = function(address, port, addressType) {
self._handle = createServerHandle(address, port, addressType);
if (!self._handle) {
process.nextTick(function() {
- self.emit('error', errnoException(errno, 'listen'));
+ self.emit('error', errnoException(__errno, 'listen'));
});
return;
}
@@ -726,7 +726,7 @@ Server.prototype._listen2 = function(address, port, addressType) {
self._handle.close();
self._handle = null;
process.nextTick(function() {
- self.emit('error', errnoException(errno, 'listen'));
+ self.emit('error', errnoException(__errno, 'listen'));
});
return;
}
@@ -810,7 +810,7 @@ function onconnection(clientHandle) {
debug('onconnection');
if (!clientHandle) {
- self.emit('error', errnoException(errno, 'accept'));
+ self.emit('error', errnoException(__errno, 'accept'));
return;
}
View
@@ -141,7 +141,7 @@ static const char* AresErrnoString(int errorno) {
static void SetAresErrno(int errorno) {
HandleScope scope;
- Handle<Value> key = String::NewSymbol("errno");
+ Handle<Value> key = String::NewSymbol("__errno");
Handle<Value> value = String::NewSymbol(AresErrnoString(errorno));
Context::GetCurrent()->Global()->Set(key, value);
}
View
@@ -962,9 +962,7 @@ void MakeCallback(Handle<Object> object,
void SetErrno(uv_err_t err) {
HandleScope scope;
- if (errno_symbol.IsEmpty()) {
- errno_symbol = NODE_PSYMBOL("errno");
- }
+ Local<String> errno_symbol = String::NewSymbol("__errno");
if (err.code == UV_UNKNOWN) {
char errno_buf[100];
View
@@ -361,7 +361,7 @@
}
if (r) {
- throw errnoException(errno, 'kill');
+ throw errnoException(__errno, 'kill');
}
};
};
View
@@ -87,8 +87,8 @@ process.on('exit', function() {
process,
global];
- if (global.errno) {
- knownGlobals.push(errno);
+ if (global.__errno) {
+ knownGlobals.push(__errno);
}
if (global.gc) {
@@ -33,7 +33,7 @@ assert.equal(0, r);
// Should not be able to bind to the same port again
var r = handle.bind('0.0.0.0', common.PORT);
assert.equal(-1, r);
-console.log(errno);
-assert.equal(errno, 'EINVAL');
+console.log(__errno);
+assert.equal(__errno, 'EINVAL');
handle.close();

0 comments on commit 53e5c67

Please sign in to comment.