Skip to content

Commit e34a2c1

Browse files
committed
uv: upgrade to 26806e2
1 parent 8dd4fcb commit e34a2c1

10 files changed

Lines changed: 223 additions & 247 deletions

File tree

deps/uv/include/uv.h

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -67,58 +67,64 @@ typedef intptr_t ssize_t;
6767
#endif
6868

6969
/* Expand this list if necessary. */
70+
#define UV_ERRNO_MAP(XX) \
71+
XX( -1, UNKNOWN, "unknown error") \
72+
XX( 0, OK, "success") \
73+
XX( 1, EOF, "end of file") \
74+
XX( 2, EADDRINFO, "getaddrinfo error") \
75+
XX( 3, EACCES, "permission denied") \
76+
XX( 4, EAGAIN, "no more processes") \
77+
XX( 5, EADDRINUSE, "address already in use") \
78+
XX( 6, EADDRNOTAVAIL, "") \
79+
XX( 7, EAFNOSUPPORT, "") \
80+
XX( 8, EALREADY, "") \
81+
XX( 9, EBADF, "bad file descriptor") \
82+
XX( 10, EBUSY, "mount device busy") \
83+
XX( 11, ECONNABORTED, "software caused connection abort") \
84+
XX( 12, ECONNREFUSED, "connection refused") \
85+
XX( 13, ECONNRESET, "connection reset by peer") \
86+
XX( 14, EDESTADDRREQ, "destination address required") \
87+
XX( 15, EFAULT, "bad address in system call argument") \
88+
XX( 16, EHOSTUNREACH, "host is unreachable") \
89+
XX( 17, EINTR, "interrupted system call") \
90+
XX( 18, EINVAL, "invalid argument") \
91+
XX( 19, EISCONN, "socket is already connected") \
92+
XX( 20, EMFILE, "too many open files") \
93+
XX( 21, EMSGSIZE, "message too long") \
94+
XX( 22, ENETDOWN, "network is down") \
95+
XX( 23, ENETUNREACH, "network is unreachable") \
96+
XX( 24, ENFILE, "file table overflow") \
97+
XX( 25, ENOBUFS, "no buffer space available") \
98+
XX( 26, ENOMEM, "not enough memory") \
99+
XX( 27, ENOTDIR, "not a directory") \
100+
XX( 28, EISDIR, "illegal operation on a directory") \
101+
XX( 29, ENONET, "machine is not on the network") \
102+
XX( 31, ENOTCONN, "socket is not connected") \
103+
XX( 32, ENOTSOCK, "socket operation on non-socket") \
104+
XX( 33, ENOTSUP, "operation not supported on socket") \
105+
XX( 34, ENOENT, "no such file or directory") \
106+
XX( 35, ENOSYS, "function not implemented") \
107+
XX( 36, EPIPE, "broken pipe") \
108+
XX( 37, EPROTO, "protocol error") \
109+
XX( 38, EPROTONOSUPPORT, "protocol not suppored") \
110+
XX( 39, EPROTOTYPE, "protocol wrong type for socket") \
111+
XX( 40, ETIMEDOUT, "connection timed out") \
112+
XX( 41, ECHARSET, "") \
113+
XX( 42, EAIFAMNOSUPPORT, "") \
114+
XX( 43, EAINONAME, "") \
115+
XX( 44, EAISERVICE, "") \
116+
XX( 45, EAISOCKTYPE, "") \
117+
XX( 46, ESHUTDOWN, "") \
118+
XX( 47, EEXIST, "file already exists") \
119+
XX( 48, ESRCH, "no such process")
120+
121+
122+
#define UV_ERRNO_GEN(val, name, s) UV_##name = val,
70123
typedef enum {
71-
UV_UNKNOWN = -1,
72-
UV_OK = 0,
73-
UV_EOF,
74-
UV_EADDRINFO,
75-
UV_EACCES,
76-
UV_EAGAIN,
77-
UV_EADDRINUSE,
78-
UV_EADDRNOTAVAIL,
79-
UV_EAFNOSUPPORT,
80-
UV_EALREADY,
81-
UV_EBADF,
82-
UV_EBUSY,
83-
UV_ECONNABORTED,
84-
UV_ECONNREFUSED,
85-
UV_ECONNRESET,
86-
UV_EDESTADDRREQ,
87-
UV_EFAULT,
88-
UV_EHOSTUNREACH,
89-
UV_EINTR,
90-
UV_EINVAL,
91-
UV_EISCONN,
92-
UV_EMFILE,
93-
UV_EMSGSIZE,
94-
UV_ENETDOWN,
95-
UV_ENETUNREACH,
96-
UV_ENFILE,
97-
UV_ENOBUFS,
98-
UV_ENOMEM,
99-
UV_ENOTDIR,
100-
UV_EISDIR,
101-
UV_ENONET,
102-
UV_ENOPROTOOPT,
103-
UV_ENOTCONN,
104-
UV_ENOTSOCK,
105-
UV_ENOTSUP,
106-
UV_ENOENT,
107-
UV_ENOSYS,
108-
UV_EPIPE,
109-
UV_EPROTO,
110-
UV_EPROTONOSUPPORT,
111-
UV_EPROTOTYPE,
112-
UV_ETIMEDOUT,
113-
UV_ECHARSET,
114-
UV_EAIFAMNOSUPPORT,
115-
UV_EAINONAME,
116-
UV_EAISERVICE,
117-
UV_EAISOCKTYPE,
118-
UV_ESHUTDOWN,
119-
UV_EEXIST,
120-
UV_ESRCH
124+
UV_ERRNO_MAP(UV_ERRNO_GEN)
125+
UV_MAX_ERRORS
121126
} uv_err_code;
127+
#undef UV_ERRNO_GEN
122128

123129
typedef enum {
124130
UV_UNKNOWN_HANDLE = 0,

deps/uv/src/unix/core.c

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ int64_t uv_timer_get_repeat(uv_timer_t* timer) {
589589
static int uv_getaddrinfo_done(eio_req* req) {
590590
uv_getaddrinfo_t* handle = req->data;
591591
struct addrinfo *res = handle->res;
592+
#if __sun
593+
size_t hostlen = strlen(handle->hostname);
594+
#endif
595+
592596
handle->res = NULL;
593597

594598
uv_unref(handle->loop);
@@ -605,6 +609,10 @@ static int uv_getaddrinfo_done(eio_req* req) {
605609
} else if (handle->retcode == EAI_NONAME) {
606610
#endif
607611
uv__set_sys_error(handle->loop, ENOENT); /* FIXME compatibility hack */
612+
#if __sun
613+
} else if (handle->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) {
614+
uv__set_sys_error(handle->loop, ENOENT);
615+
#endif
608616
} else {
609617
handle->loop->last_err.code = UV_EADDRINFO;
610618
handle->loop->last_err.sys_errno_ = handle->retcode;
@@ -686,22 +694,30 @@ void uv_freeaddrinfo(struct addrinfo* ai) {
686694

687695
/* Open a socket in non-blocking close-on-exec mode, atomically if possible. */
688696
int uv__socket(int domain, int type, int protocol) {
689-
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
690-
return socket(domain, type | SOCK_NONBLOCK | SOCK_CLOEXEC, protocol);
691-
#else
692697
int sockfd;
693698

694-
if ((sockfd = socket(domain, type, protocol)) == -1) {
695-
return -1;
696-
}
699+
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
700+
sockfd = socket(domain, type | SOCK_NONBLOCK | SOCK_CLOEXEC, protocol);
697701

698-
if (uv__nonblock(sockfd, 1) == -1 || uv__cloexec(sockfd, 1) == -1) {
702+
if (sockfd != -1)
703+
goto out;
704+
705+
if (errno != EINVAL)
706+
goto out;
707+
#endif
708+
709+
sockfd = socket(domain, type, protocol);
710+
711+
if (sockfd == -1)
712+
goto out;
713+
714+
if (uv__nonblock(sockfd, 1) || uv__cloexec(sockfd, 1)) {
699715
uv__close(sockfd);
700-
return -1;
716+
sockfd = -1;
701717
}
702718

719+
out:
703720
return sockfd;
704-
#endif
705721
}
706722

707723

@@ -710,19 +726,34 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
710726

711727
assert(sockfd >= 0);
712728

713-
do {
714-
#if defined(HAVE_ACCEPT4)
729+
while (1) {
730+
#if HAVE_ACCEPT4
715731
peerfd = accept4(sockfd, saddr, &slen, SOCK_NONBLOCK | SOCK_CLOEXEC);
716-
#else
717-
if ((peerfd = accept(sockfd, saddr, &slen)) != -1) {
718-
if (uv__cloexec(peerfd, 1) == -1 || uv__nonblock(peerfd, 1) == -1) {
719-
uv__close(peerfd);
720-
return -1;
721-
}
722-
}
732+
733+
if (peerfd != -1)
734+
break;
735+
736+
if (errno == EINTR)
737+
continue;
738+
739+
if (errno != ENOSYS)
740+
break;
723741
#endif
742+
743+
if ((peerfd = accept(sockfd, saddr, &slen)) == -1) {
744+
if (errno == EINTR)
745+
continue;
746+
else
747+
break;
748+
}
749+
750+
if (uv__cloexec(peerfd, 1) || uv__nonblock(peerfd, 1)) {
751+
uv__close(peerfd);
752+
peerfd = -1;
753+
}
754+
755+
break;
724756
}
725-
while (peerfd == -1 && errno == EINTR);
726757

727758
return peerfd;
728759
}

deps/uv/src/unix/error.c

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -56,38 +56,6 @@ void uv_fatal_error(const int errorno, const char* syscall) {
5656
}
5757

5858

59-
static int uv__translate_lib_error(int code) {
60-
switch (code) {
61-
case UV_ENOSYS: return ENOSYS;
62-
case UV_ENOTSOCK: return ENOTSOCK;
63-
case UV_ENOENT: return ENOENT;
64-
case UV_EACCES: return EACCES;
65-
case UV_EAFNOSUPPORT: return EAFNOSUPPORT;
66-
case UV_EBADF: return EBADF;
67-
case UV_EPIPE: return EPIPE;
68-
case UV_EAGAIN: return EAGAIN;
69-
case UV_ECONNRESET: return ECONNRESET;
70-
case UV_EFAULT: return EFAULT;
71-
case UV_EMFILE: return EMFILE;
72-
case UV_EMSGSIZE: return EMSGSIZE;
73-
case UV_EINVAL: return EINVAL;
74-
case UV_ECONNREFUSED: return ECONNREFUSED;
75-
case UV_EADDRINUSE: return EADDRINUSE;
76-
case UV_EADDRNOTAVAIL: return EADDRNOTAVAIL;
77-
case UV_ENOTDIR: return ENOTDIR;
78-
case UV_EISDIR: return EISDIR;
79-
case UV_ENOTCONN: return ENOTCONN;
80-
case UV_EEXIST: return EEXIST;
81-
case UV_EHOSTUNREACH: return EHOSTUNREACH;
82-
case UV_ESRCH: return ESRCH;
83-
default: return -1;
84-
}
85-
86-
assert(0 && "unreachable");
87-
return -1;
88-
}
89-
90-
9159
uv_err_code uv_translate_sys_error(int sys_errno) {
9260
switch (sys_errno) {
9361
case 0: return UV_OK;
@@ -120,25 +88,3 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
12088
assert(0 && "unreachable");
12189
return -1;
12290
}
123-
124-
125-
/* TODO Pull in error messages so we don't have to
126-
* a) rely on what the system provides us
127-
* b) reverse-map the error codes
128-
*/
129-
const char* uv_strerror(uv_err_t err) {
130-
int errorno;
131-
132-
if (err.sys_errno_)
133-
errorno = err.sys_errno_;
134-
else
135-
errorno = uv__translate_lib_error(err.code);
136-
137-
if (err.code == UV_EADDRINFO)
138-
return gai_strerror(errorno);
139-
140-
if (errorno == -1)
141-
return "Unknown error";
142-
else
143-
return strerror(errorno);
144-
}

deps/uv/src/unix/freebsd.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ uint64_t uv_hrtime(void) {
4343

4444

4545
int uv_exepath(char* buffer, size_t* size) {
46-
uint32_t usize;
47-
int result;
48-
char* path;
49-
char* fullpath;
5046
int mib[4];
5147
size_t cb;
5248

0 commit comments

Comments
 (0)