mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Display sys_errno when UV_UNKNOWN is returned
This commit is contained in:
1 parent
88af0c8635
commit
6cc42927d8
11 files changed
+80
-52
No files matched your search
@@ -13,7 +13,9 @@ namespace node {
|
||||
FSEventWrap* wrap = \
|
||||
static_cast<FSEventWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ Handle<Value> FSEventWrap::Start(const Arguments& args) {
|
||||
uv_unref(uv_default_loop());
|
||||
}
|
||||
} else {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
@@ -106,7 +108,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
|
||||
assert(wrap->object_.IsEmpty() == false);
|
||||
|
||||
if (status) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
eventStr = String::Empty();
|
||||
} else {
|
||||
switch (events) {
|
||||
|
||||
+3
-1
@@ -24,7 +24,9 @@ using v8::Integer;
|
||||
HandleWrap* wrap = \
|
||||
static_cast<HandleWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
|
||||
+16
-6
@@ -1004,7 +1004,7 @@ Local<Value> ErrnoException(int errorno,
|
||||
Local<String> cons1 = String::Concat(estring, String::NewSymbol(", "));
|
||||
Local<String> cons2 = String::Concat(cons1, message);
|
||||
|
||||
if (errno_symbol.IsEmpty()) {
|
||||
if (syscall_symbol.IsEmpty()) {
|
||||
syscall_symbol = NODE_PSYMBOL("syscall");
|
||||
errno_symbol = NODE_PSYMBOL("errno");
|
||||
errpath_symbol = NODE_PSYMBOL("path");
|
||||
@@ -1080,11 +1080,21 @@ void MakeCallback(Handle<Object> object,
|
||||
}
|
||||
|
||||
|
||||
void SetErrno(uv_err_code code) {
|
||||
uv_err_t err;
|
||||
err.code = code;
|
||||
Context::GetCurrent()->Global()->Set(String::NewSymbol("errno"),
|
||||
String::NewSymbol(uv_err_name(err)));
|
||||
void SetErrno(uv_err_t err) {
|
||||
HandleScope scope;
|
||||
|
||||
if (errno_symbol.IsEmpty()) {
|
||||
errno_symbol = NODE_PSYMBOL("errno");
|
||||
}
|
||||
|
||||
if (err.code == UV_UNKNOWN) {
|
||||
char errno_buf[100];
|
||||
snprintf(errno_buf, 100, "Unknown system errno %d", err.sys_errno_);
|
||||
Context::GetCurrent()->Global()->Set(errno_symbol, String::New(errno_buf));
|
||||
} else {
|
||||
Context::GetCurrent()->Global()->Set(errno_symbol,
|
||||
String::NewSymbol(uv_err_name(err)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ node_module_struct* get_builtin_module(const char *name);
|
||||
#define NODE_MODULE_DECL(modname) \
|
||||
extern node::node_module_struct modname ## _module;
|
||||
|
||||
void SetErrno(uv_err_code code);
|
||||
void SetErrno(uv_err_t err);
|
||||
void MakeCallback(v8::Handle<v8::Object> object,
|
||||
const char* method,
|
||||
int argc,
|
||||
|
||||
+7
-5
@@ -11,7 +11,9 @@
|
||||
PipeWrap* wrap = \
|
||||
static_cast<PipeWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -113,7 +115,7 @@ Handle<Value> PipeWrap::Bind(const Arguments& args) {
|
||||
int r = uv_pipe_bind(&wrap->handle_, *name);
|
||||
|
||||
// Error starting the pipe.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -129,7 +131,7 @@ Handle<Value> PipeWrap::Listen(const Arguments& args) {
|
||||
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
|
||||
|
||||
// Error starting the pipe.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -182,7 +184,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
|
||||
assert(wrap->object_.IsEmpty() == false);
|
||||
|
||||
if (status) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
|
||||
Local<Value> argv[3] = {
|
||||
@@ -227,7 +229,7 @@ Handle<Value> PipeWrap::Connect(const Arguments& args) {
|
||||
req_wrap->Dispatched();
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
delete req_wrap;
|
||||
return scope.Close(v8::Null());
|
||||
} else {
|
||||
|
||||
+5
-3
@@ -10,7 +10,9 @@
|
||||
ProcessWrap* wrap = \
|
||||
static_cast<ProcessWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -172,7 +174,7 @@ class ProcessWrap : public HandleWrap {
|
||||
delete [] options.env;
|
||||
}
|
||||
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -186,7 +188,7 @@ class ProcessWrap : public HandleWrap {
|
||||
|
||||
int r = uv_process_kill(&wrap->process_, signal);
|
||||
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
|
||||
+10
-8
@@ -34,7 +34,9 @@ using v8::Integer;
|
||||
StreamWrap* wrap = \
|
||||
static_cast<StreamWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -106,7 +108,7 @@ Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
|
||||
}
|
||||
|
||||
// Error starting the tcp.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -120,7 +122,7 @@ Handle<Value> StreamWrap::ReadStop(const Arguments& args) {
|
||||
int r = uv_read_stop(wrap->stream_);
|
||||
|
||||
// Error starting the tcp.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -199,7 +201,7 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle, ssize_t nread,
|
||||
slab_used -= buf.len;
|
||||
}
|
||||
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
MakeCallback(wrap->object_, "onread", 0, NULL);
|
||||
return;
|
||||
}
|
||||
@@ -312,7 +314,7 @@ Handle<Value> StreamWrap::Write(const Arguments& args) {
|
||||
wrap->UpdateWriteQueueSize();
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
delete req_wrap;
|
||||
return scope.Close(v8::Null());
|
||||
} else {
|
||||
@@ -332,7 +334,7 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
|
||||
assert(wrap->object_.IsEmpty() == false);
|
||||
|
||||
if (status) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
|
||||
wrap->UpdateWriteQueueSize();
|
||||
@@ -362,7 +364,7 @@ Handle<Value> StreamWrap::Shutdown(const Arguments& args) {
|
||||
req_wrap->Dispatched();
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
delete req_wrap;
|
||||
return scope.Close(v8::Null());
|
||||
} else {
|
||||
@@ -382,7 +384,7 @@ void StreamWrap::AfterShutdown(uv_shutdown_t* req, int status) {
|
||||
HandleScope scope;
|
||||
|
||||
if (status) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
|
||||
Local<Value> argv[3] = {
|
||||
|
||||
+12
-10
@@ -28,7 +28,9 @@
|
||||
TCPWrap* wrap = \
|
||||
static_cast<TCPWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -149,7 +151,7 @@ Handle<Value> TCPWrap::GetSockName(const Arguments& args) {
|
||||
|
||||
Local<Object> sockname = Object::New();
|
||||
if (r != 0) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
} else {
|
||||
family = address.ss_family;
|
||||
|
||||
@@ -191,7 +193,7 @@ Handle<Value> TCPWrap::GetPeerName(const Arguments& args) {
|
||||
|
||||
Local<Object> sockname = Object::New();
|
||||
if (r != 0) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
} else {
|
||||
family = address.ss_family;
|
||||
|
||||
@@ -229,7 +231,7 @@ Handle<Value> TCPWrap::Bind(const Arguments& args) {
|
||||
int r = uv_tcp_bind(&wrap->handle_, address);
|
||||
|
||||
// Error starting the tcp.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -247,7 +249,7 @@ Handle<Value> TCPWrap::Bind6(const Arguments& args) {
|
||||
int r = uv_tcp_bind6(&wrap->handle_, address);
|
||||
|
||||
// Error starting the tcp.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -263,7 +265,7 @@ Handle<Value> TCPWrap::Listen(const Arguments& args) {
|
||||
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
|
||||
|
||||
// Error starting the tcp.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -298,7 +300,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
|
||||
// Successful accept. Call the onconnection callback in JavaScript land.
|
||||
argv[0] = client_obj;
|
||||
} else {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
argv[0] = v8::Null();
|
||||
}
|
||||
|
||||
@@ -317,7 +319,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
|
||||
assert(wrap->object_.IsEmpty() == false);
|
||||
|
||||
if (status) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
|
||||
Local<Value> argv[3] = {
|
||||
@@ -353,7 +355,7 @@ Handle<Value> TCPWrap::Connect(const Arguments& args) {
|
||||
req_wrap->Dispatched();
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
delete req_wrap;
|
||||
return scope.Close(v8::Null());
|
||||
} else {
|
||||
@@ -380,7 +382,7 @@ Handle<Value> TCPWrap::Connect6(const Arguments& args) {
|
||||
req_wrap->Dispatched();
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
delete req_wrap;
|
||||
return scope.Close(v8::Null());
|
||||
} else {
|
||||
|
||||
+7
-5
@@ -7,7 +7,9 @@
|
||||
TimerWrap* wrap = \
|
||||
static_cast<TimerWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ class TimerWrap : public HandleWrap {
|
||||
int r = uv_timer_start(&wrap->handle_, OnTimeout, timeout, repeat);
|
||||
|
||||
// Error starting the timer.
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
wrap->StateChange();
|
||||
|
||||
@@ -123,7 +125,7 @@ class TimerWrap : public HandleWrap {
|
||||
|
||||
int r = uv_timer_stop(&wrap->handle_);
|
||||
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
wrap->StateChange();
|
||||
|
||||
@@ -137,7 +139,7 @@ class TimerWrap : public HandleWrap {
|
||||
|
||||
int r = uv_timer_again(&wrap->handle_);
|
||||
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (r) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
wrap->StateChange();
|
||||
|
||||
@@ -163,7 +165,7 @@ class TimerWrap : public HandleWrap {
|
||||
|
||||
int64_t repeat = uv_timer_get_repeat(&wrap->handle_);
|
||||
|
||||
if (repeat < 0) SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
if (repeat < 0) SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(repeat));
|
||||
}
|
||||
|
||||
+5
-3
@@ -27,7 +27,9 @@ using v8::Undefined;
|
||||
TTYWrap* wrap = \
|
||||
static_cast<TTYWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -100,7 +102,7 @@ class TTYWrap : StreamWrap {
|
||||
int r = uv_tty_get_winsize(&wrap->handle_, &width, &height);
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
@@ -119,7 +121,7 @@ class TTYWrap : StreamWrap {
|
||||
int r = uv_tty_set_mode(&wrap->handle_, args[0]->IsTrue());
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
|
||||
+9
-7
@@ -32,7 +32,9 @@ namespace node {
|
||||
UDPWrap* wrap = \
|
||||
static_cast<UDPWrap*>(args.Holder()->GetPointerFromInternalField(0)); \
|
||||
if (!wrap) { \
|
||||
SetErrno(UV_EBADF); \
|
||||
uv_err_t err; \
|
||||
err.code = UV_EBADF; \
|
||||
SetErrno(err); \
|
||||
return scope.Close(Integer::New(-1)); \
|
||||
}
|
||||
|
||||
@@ -153,7 +155,7 @@ Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) {
|
||||
}
|
||||
|
||||
if (r)
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
|
||||
return scope.Close(Integer::New(r));
|
||||
}
|
||||
@@ -210,7 +212,7 @@ Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) {
|
||||
req_wrap->Dispatched();
|
||||
|
||||
if (r) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
delete req_wrap;
|
||||
return Null();
|
||||
}
|
||||
@@ -238,7 +240,7 @@ Handle<Value> UDPWrap::RecvStart(const Arguments& args) {
|
||||
// UV_EALREADY means that the socket is already bound but that's okay
|
||||
int r = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv);
|
||||
if (r && uv_last_error(uv_default_loop()).code != UV_EALREADY) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
return False();
|
||||
}
|
||||
|
||||
@@ -274,7 +276,7 @@ Handle<Value> UDPWrap::GetSockName(const Arguments& args) {
|
||||
return scope.Close(sockname);
|
||||
}
|
||||
else {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
return Null();
|
||||
}
|
||||
}
|
||||
@@ -293,7 +295,7 @@ void UDPWrap::OnSend(uv_udp_send_t* req, int status) {
|
||||
assert(wrap->object_.IsEmpty() == false);
|
||||
|
||||
if (status) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
|
||||
Local<Value> argv[4] = {
|
||||
@@ -341,7 +343,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
|
||||
};
|
||||
|
||||
if (nread == -1) {
|
||||
SetErrno(uv_last_error(uv_default_loop()).code);
|
||||
SetErrno(uv_last_error(uv_default_loop()));
|
||||
}
|
||||
else {
|
||||
Local<Object> rinfo = Object::New();
|
||||
|
||||
Reference in new issue
Block a user