ext/libuv/src/unix/stream.c in libuv-2.0.6 vs ext/libuv/src/unix/stream.c in libuv-2.0.8
- old
+ new
@@ -944,25 +944,34 @@
}
uv_handle_type uv__handle_type(int fd) {
struct sockaddr_storage ss;
+ socklen_t sslen;
socklen_t len;
int type;
memset(&ss, 0, sizeof(ss));
- len = sizeof(ss);
+ sslen = sizeof(ss);
- if (getsockname(fd, (struct sockaddr*)&ss, &len))
+ if (getsockname(fd, (struct sockaddr*)&ss, &sslen))
return UV_UNKNOWN_HANDLE;
len = sizeof type;
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &len))
return UV_UNKNOWN_HANDLE;
if (type == SOCK_STREAM) {
+#if defined(_AIX)
+ /* on AIX the getsockname call returns an empty sa structure
+ * for sockets of type AF_UNIX. For all other types it will
+ * return a properly filled in structure.
+ */
+ if (sslen == 0)
+ return UV_NAMED_PIPE;
+#endif
switch (ss.ss_family) {
case AF_UNIX:
return UV_NAMED_PIPE;
case AF_INET:
case AF_INET6:
@@ -1080,10 +1089,15 @@
return 0;
}
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wgnu-folding-constant"
+#endif
+
static void uv__read(uv_stream_t* stream) {
uv_buf_t buf;
ssize_t nread;
struct msghdr msg;
char cmsg_space[CMSG_SPACE(UV__CMSG_FD_SIZE)];
@@ -1184,9 +1198,13 @@
}
}
}
}
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
#undef UV__CMSG_FD_COUNT
#undef UV__CMSG_FD_SIZE