Non-release upgrade so pending patches can land.
/aclocal.m4
/ar-lib
/autom4te.cache/
+/compile
/config.guess
/config.log
/config.status
-2013.07.21, Version 0.11.6 (Unstable)
+2013.07.26, Version 0.10.13 (Stable), 381312e1fe6fecbabc943ccd56f0e7d114b3d064
+
+Changes since version 0.10.12:
+
+* unix, windows: fix uv_fs_chown() function prototype (Ben Noordhuis)
+
+
+2013.07.21, Version 0.11.6 (Unstable), 6645b93273e0553d23823c576573b82b129bf28c
Changes since version 0.11.5:
* unix, windows: return error codes directly (Ben Noordhuis)
+2013.07.10, Version 0.10.12 (Stable), 58a46221bba726746887a661a9f36fe9ff204209
+
+Changes since version 0.10.11:
+
+* linux: add support for MIPS (Andrei Sedoi)
+
+* windows: uv_spawn shouldn't reject reparse points (Bert Belder)
+
+* windows: use WSAGetLastError(), not errno (Ben Noordhuis)
+
+* build: darwin: disable -fstrict-aliasing warnings (Ben Noordhuis)
+
+* build: `all` now builds static and dynamic lib (Ben Noordhuis)
+
+* unix: fix build when !defined(PTHREAD_MUTEX_ERRORCHECK) (Ben Noordhuis)
+
+
2013.06.27, Version 0.11.5 (Unstable), e3c63ff1627a14e96f54c1c62b0d68b446d8425b
Changes since version 0.11.4:
if DTRACE_NEEDS_OBJECTS
libuv_la_SOURCES += src/unix/uv-dtrace.d
libuv_la_DEPENDENCIES = src/unix/uv-dtrace.o
-libuv_la_LIBADD = src/unix/uv-dtrace.lo
+libuv_la_LIBADD = uv-dtrace.lo
CLEANFILES += src/unix/uv-dtrace.o src/unix/uv-dtrace.lo
endif
SUFFIXES = .d
include/uv-dtrace.h: src/unix/uv-dtrace.d
- $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -h -xnolibs -s $< -o $@
+ $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -h -xnolibs -s $< -o $(top_srcdir)/$@
src/unix/uv-dtrace.o: src/unix/uv-dtrace.d ${libuv_la_OBJECTS}
+# It's ok to specify the output here, because we have 1 .d file, and we process
+# every created .o, most projects don't need to include more than one .d
.d.o:
- $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -G -o $@ -s $< \
- `grep '^pic_object' ${top_builddir}/*.lo | cut -f 2 -d\'`
+ $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -G -o $(top_builddir)/uv-dtrace.o -s $< \
+ `grep '^pic_object' $$(find ${top_builddir} -name "*.lo") | cut -f 2 -d\'`
$(AM_V_GEN)printf %s\\n \
- '# $(patsubst %.o, %.lo, $@) - a libtool object file' \
+ '# ${top_builddir}/uv-dtrace.lo - a libtool object file' \
'# Generated by libtool (GNU libtool) 2.4' \
'# libtool wants a .lo not a .o' \
"pic_object='uv-dtrace.o'" \
"non_pic_object='uv-dtrace.o'" \
- > $(patsubst %.o, %.lo, $@)
+ > ${top_builddir}/uv-dtrace.lo
--- /dev/null
+# Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+CFLAGS = -Wall \
+ -Wextra \
+ -Wno-unused-parameter \
+ -Iinclude \
+ -Isrc \
+ -Isrc/win \
+ -DWIN32_LEAN_AND_MEAN \
+ -D_WIN32_WINNT=0x0600
+
+INCLUDES = include/stdint-msvc2008.h \
+ include/tree.h \
+ include/uv-errno.h \
+ include/uv-win.h \
+ include/uv.h \
+ src/queue.h \
+ src/uv-common.h \
+ src/win/atomicops-inl.h \
+ src/win/handle-inl.h \
+ src/win/internal.h \
+ src/win/req-inl.h \
+ src/win/stream-inl.h \
+ src/win/winapi.h \
+ src/win/winsock.h
+
+OBJS = src/fs-poll.o \
+ src/inet.o \
+ src/uv-common.o \
+ src/version.o \
+ src/win/async.o \
+ src/win/core.o \
+ src/win/dl.o \
+ src/win/error.o \
+ src/win/fs-event.o \
+ src/win/fs.o \
+ src/win/getaddrinfo.o \
+ src/win/handle.o \
+ src/win/loop-watcher.o \
+ src/win/pipe.o \
+ src/win/poll.o \
+ src/win/process-stdio.o \
+ src/win/process.o \
+ src/win/req.o \
+ src/win/signal.o \
+ src/win/stream.o \
+ src/win/tcp.o \
+ src/win/thread.o \
+ src/win/threadpool.o \
+ src/win/timer.o \
+ src/win/tty.o \
+ src/win/udp.o \
+ src/win/util.o \
+ src/win/winapi.o \
+ src/win/winsock.o
+
+all: libuv.a
+
+libuv.a: $(OBJS)
+ $(AR) crs $@ $^
+
+# FIXME(bnoordhuis) Don't rebuild everything when a source file changes.
+$(OBJS): $(OBJS:.o=.c) $(INCLUDES)
AC_PREREQ(2.57)
AC_INIT([libuv], [0.11.5], [https://github.com/joyent/libuv/issues])
-AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
AC_ENABLE_SHARED
AC_ENABLE_STATIC
AC_PROG_CC
+AM_PROG_CC_C_O
# AM_PROG_AR is not available in automake v0.11 but it's essential in v0.12.
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
void* buf; \
size_t len; \
off_t off; \
- uid_t uid; \
- gid_t gid; \
+ uv_uid_t uid; \
+ uv_gid_t gid; \
double atime; \
double mtime; \
struct uv__work work_req; \
*
* `suggested_size` is a hint. Returning a buffer that is smaller is perfectly
* okay as long as `buf.len > 0`.
+ *
+ * If you return a buffer with `buf.len == 0`, libuv skips the read and calls
+ * your read or recv callback with nread=UV_ENOBUFS.
+ *
+ * Note that returning a zero-length buffer does not stop the handle, call
+ * uv_read_stop() or uv_udp_recv_stop() for that.
*/
typedef uv_buf_t (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);
struct uv_interface_address_s {
char* name;
+ char phys_addr[6];
int is_internal;
union {
struct sockaddr_in address4;
uv_fs_cb cb);
UV_EXTERN int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file,
- void* buf, size_t length, int64_t offset, uv_fs_cb cb);
+ const void* buf, size_t length, int64_t offset, uv_fs_cb cb);
UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
int mode, uv_fs_cb cb);
int mode, uv_fs_cb cb);
UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path,
- int uid, int gid, uv_fs_cb cb);
+ uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);
UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file,
- int uid, int gid, uv_fs_cb cb);
+ uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb);
enum uv_fs_event {
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
close(sockfd);
- return uv__new_artificial_error(UV_ENOSYS);
+ return -ENOSYS;
}
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
close(sockfd);
- return uv__new_artificial_error(UV_ENOSYS);
+ return -ENOSYS;
}
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
#include <ifaddrs.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <CoreFoundation/CFRunLoop.h>
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
struct ifaddrs *addrs, *ent;
uv_interface_address_t* address;
+ int i;
+ struct sockaddr_dl *sa_addr;
if (getifaddrs(&addrs))
return -errno;
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING) ||
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
(ent->ifa_addr == NULL) ||
(ent->ifa_addr->sa_family == AF_LINK)) {
continue;
address = *addresses;
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING)) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
continue;
- }
- if (ent->ifa_addr == NULL) {
+ if (ent->ifa_addr == NULL)
continue;
- }
/*
* On Mac OS X getifaddrs returns information related to Mac Addresses for
* various devices, such as firewire, etc. These are not relevant here.
*/
- if (ent->ifa_addr->sa_family == AF_LINK) {
+ if (ent->ifa_addr->sa_family == AF_LINK)
continue;
- }
address->name = strdup(ent->ifa_name);
address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
}
- address->is_internal = ent->ifa_flags & IFF_LOOPBACK ? 1 : 0;
+ address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK);
address++;
}
+ /* Fill in physical addresses for each interface */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family != AF_LINK)) {
+ continue;
+ }
+
+ address = *addresses;
+
+ for (i = 0; i < (*count); i++) {
+ if (strcmp(address->name, ent->ifa_name) == 0) {
+ sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
+ memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+ }
+ address++;
+ }
+ }
+
freeifaddrs(addrs);
return 0;
#include <string.h>
#include <errno.h>
+#include <ifaddrs.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+
#include <kvm.h>
#include <paths.h>
#include <sys/user.h>
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
- /* TODO: implement */
- *addresses = NULL;
- *count = 0;
+ struct ifaddrs *addrs, *ent;
+ uv_interface_address_t* address;
+ int i;
+ struct sockaddr_dl *sa_addr;
+
+ if (getifaddrs(&addrs))
+ return -errno;
+
+ *count = 0;
+
+ /* Count the number of interfaces */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family == AF_LINK)) {
+ continue;
+ }
+
+ (*count)++;
+ }
+
+ *addresses = malloc(*count * sizeof(**addresses));
+ if (!(*addresses))
+ return -ENOMEM;
+
+ address = *addresses;
+
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
+ continue;
+
+ if (ent->ifa_addr == NULL)
+ continue;
+
+ /*
+ * On FreeBSD getifaddrs returns information related to the raw underlying
+ * devices. We're not interested in this information yet.
+ */
+ if (ent->ifa_addr->sa_family == AF_LINK)
+ continue;
+
+ address->name = strdup(ent->ifa_name);
+
+ if (ent->ifa_addr->sa_family == AF_INET6) {
+ address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr);
+ } else {
+ address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr);
+ }
+
+ if (ent->ifa_netmask->sa_family == AF_INET6) {
+ address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask);
+ } else {
+ address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
+ }
+
+ address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK);
+
+ address++;
+ }
+
+ /* Fill in physical addresses for each interface */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family != AF_LINK)) {
+ continue;
+ }
+
+ address = *addresses;
+
+ for (i = 0; i < (*count); i++) {
+ if (strcmp(address->name, ent->ifa_name) == 0) {
+ sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
+ memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+ }
+ address++;
+ }
+ }
+
+ freeifaddrs(addrs);
+
return 0;
}
void uv_free_interface_addresses(uv_interface_address_t* addresses,
int count) {
+ int i;
+
+ for (i = 0; i < count; i++) {
+ free(addresses[i].name);
+ }
+
+ free(addresses);
}
int uv_fs_chown(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
- int uid,
- int gid,
+ uv_uid_t uid,
+ uv_gid_t gid,
uv_fs_cb cb) {
INIT(CHOWN);
PATH;
int uv_fs_fchown(uv_loop_t* loop,
uv_fs_t* req,
uv_file file,
- int uid,
- int gid,
+ uv_uid_t uid,
+ uv_gid_t gid,
uv_fs_cb cb) {
INIT(FCHOWN);
req->file = file;
int uv_fs_write(uv_loop_t* loop,
uv_fs_t* req,
uv_file file,
- void* buf,
+ const void* buf,
size_t len,
int64_t off,
uv_fs_cb cb) {
INIT(WRITE);
req->file = file;
- req->buf = buf;
+ req->buf = (void*) buf;
req->len = len;
req->off = off;
POST;
#endif
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
+# include <sys/socket.h>
+# include <net/ethernet.h>
+# include <linux/if_packet.h>
#endif
#undef NANOSEC
return -ENOSYS;
#else
struct ifaddrs *addrs, *ent;
- char ip[INET6_ADDRSTRLEN];
uv_interface_address_t* address;
+ int i;
+ struct sockaddr_ll *sll;
if (getifaddrs(&addrs))
return -errno;
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING) ||
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
(ent->ifa_addr == NULL) ||
(ent->ifa_addr->sa_family == PF_PACKET)) {
continue;
address = *addresses;
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- bzero(&ip, sizeof (ip));
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING)) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
continue;
- }
- if (ent->ifa_addr == NULL) {
+ if (ent->ifa_addr == NULL)
continue;
- }
/*
* On Linux getifaddrs returns information related to the raw underlying
- * devices. We're not interested in this information.
+ * devices. We're not interested in this information yet.
*/
- if (ent->ifa_addr->sa_family == PF_PACKET) {
+ if (ent->ifa_addr->sa_family == PF_PACKET)
continue;
- }
address->name = strdup(ent->ifa_name);
address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
}
- address->is_internal = ent->ifa_flags & IFF_LOOPBACK ? 1 : 0;
+ address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK);
address++;
}
+ /* Fill in physical addresses for each interface */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family != PF_PACKET)) {
+ continue;
+ }
+
+ address = *addresses;
+
+ for (i = 0; i < (*count); i++) {
+ if (strcmp(address->name, ent->ifa_name) == 0) {
+ sll = (struct sockaddr_ll*)ent->ifa_addr;
+ memcpy(address->phys_addr, sll->sll_addr, sizeof(address->phys_addr));
+ }
+ address++;
+ }
+ }
+
freeifaddrs(addrs);
return 0;
#include <fcntl.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/sysctl.h>
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
- struct ifaddrs *addrs;
- struct ifaddrs *ent;
+ struct ifaddrs *addrs, *ent;
uv_interface_address_t* address;
+ int i;
+ struct sockaddr_dl *sa_addr;
if (getifaddrs(&addrs))
return -errno;
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING) ||
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
(ent->ifa_addr == NULL) ||
(ent->ifa_addr->sa_family != PF_INET)) {
continue;
address = *addresses;
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING)) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
continue;
- }
- if (ent->ifa_addr == NULL) {
+ if (ent->ifa_addr == NULL)
continue;
- }
- if (ent->ifa_addr->sa_family != PF_INET) {
+ if (ent->ifa_addr->sa_family != PF_INET)
continue;
- }
address->name = strdup(ent->ifa_name);
address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
}
- address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK) ? 1 : 0;
+ address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK);
address++;
}
+ /* Fill in physical addresses for each interface */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family != AF_LINK)) {
+ continue;
+ }
+
+ address = *addresses;
+
+ for (i = 0; i < (*count); i++) {
+ if (strcmp(address->name, ent->ifa_name) == 0) {
+ sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
+ memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+ }
+ address++;
+ }
+ }
+
freeifaddrs(addrs);
return 0;
#include <sys/time.h>
#include <sys/sysctl.h>
+#include <ifaddrs.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+
#include <errno.h>
#include <fcntl.h>
#include <kvm.h>
int uv_interface_addresses(uv_interface_address_t** addresses,
int* count) {
- /* TODO: implement */
- *addresses = NULL;
- *count = 0;
+ struct ifaddrs *addrs, *ent;
+ uv_interface_address_t* address;
+ int i;
+ struct sockaddr_dl *sa_addr;
+
+ if (getifaddrs(&addrs) != 0)
+ return -errno;
+
+ *count = 0;
+
+ /* Count the number of interfaces */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family != PF_INET)) {
+ continue;
+ }
+ (*count)++;
+ }
+
+ *addresses = malloc(*count * sizeof(**addresses));
+
+ if (!(*addresses))
+ return -ENOMEM;
+
+ address = *addresses;
+
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
+ continue;
+
+ if (ent->ifa_addr == NULL)
+ continue;
+
+ if (ent->ifa_addr->sa_family != PF_INET)
+ continue;
+
+ address->name = strdup(ent->ifa_name);
+
+ if (ent->ifa_addr->sa_family == AF_INET6) {
+ address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr);
+ } else {
+ address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr);
+ }
+
+ if (ent->ifa_netmask->sa_family == AF_INET6) {
+ address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask);
+ } else {
+ address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
+ }
+
+ address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK);
+
+ address++;
+ }
+
+ /* Fill in physical addresses for each interface */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family != AF_LINK)) {
+ continue;
+ }
+
+ address = *addresses;
+
+ for (i = 0; i < (*count); i++) {
+ if (strcmp(address->name, ent->ifa_name) == 0) {
+ sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
+ memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+ }
+ address++;
+ }
+ }
+
+ freeifaddrs(addrs);
+
return 0;
}
void uv_free_interface_addresses(uv_interface_address_t* addresses,
int count) {
+ int i;
+
+ for (i = 0; i < count; i++) {
+ free(addresses[i].name);
+ }
+
+ free(addresses);
}
while ((stream->read_cb || stream->read2_cb)
&& (stream->flags & UV_STREAM_READING)
&& (count-- > 0)) {
- assert(stream->alloc_cb);
+ assert(stream->alloc_cb != NULL);
+
buf = stream->alloc_cb((uv_handle_t*)stream, 64 * 1024);
+ if (buf.len == 0) {
+ /* User indicates it can't or won't handle the read. */
+ uv__stream_read_cb(stream, UV_ENOBUFS, buf, UV_UNKNOWN_HANDLE);
+ return;
+ }
- assert(buf.len > 0);
- assert(buf.base);
+ assert(buf.base != NULL);
assert(uv__stream_fd(stream) >= 0);
if (stream->read_cb) {
# include <ifaddrs.h>
#endif
#include <net/if.h>
+#include <net/if_dl.h>
#include <sys/loadavg.h>
#include <sys/time.h>
#ifdef SUNOS_NO_IFADDRS
return -ENOSYS;
#else
- struct ifaddrs *addrs, *ent;
- char ip[INET6_ADDRSTRLEN];
uv_interface_address_t* address;
+ struct sockaddr_dl* sa_addr;
+ struct ifaddrs* addrs;
+ struct ifaddrs* ent;
+ int i;
if (getifaddrs(&addrs))
return -errno;
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING) ||
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
(ent->ifa_addr == NULL) ||
(ent->ifa_addr->sa_family == PF_PACKET)) {
continue;
address = *addresses;
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- memset(&ip, 0, sizeof(ip));
-
- if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING)) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
continue;
- }
- if (ent->ifa_addr == NULL) {
+ if (ent->ifa_addr == NULL)
continue;
- }
address->name = strdup(ent->ifa_name);
address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
}
- address->is_internal = ent->ifa_flags & IFF_PRIVATE || ent->ifa_flags &
- IFF_LOOPBACK ? 1 : 0;
+ address->is_internal = !!((ent->ifa_flags & IFF_PRIVATE) ||
+ (ent->ifa_flags & IFF_LOOPBACK));
address++;
}
+ /* Fill in physical addresses for each interface */
+ for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
+ (ent->ifa_addr == NULL) ||
+ (ent->ifa_addr->sa_family != AF_LINK)) {
+ continue;
+ }
+
+ address = *addresses;
+
+ for (i = 0; i < (*count); i++) {
+ if (strcmp(address->name, ent->ifa_name) == 0) {
+ sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
+ memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+ }
+ address++;
+ }
+ }
+
freeifaddrs(addrs);
return 0;
h.msg_name = &peer;
do {
- buf = handle->alloc_cb((uv_handle_t*)handle, 64 * 1024);
- assert(buf.len > 0);
+ buf = handle->alloc_cb((uv_handle_t*) handle, 64 * 1024);
+ if (buf.len == 0) {
+ handle->recv_cb(handle, UV_ENOBUFS, buf, NULL, 0);
+ return;
+ }
assert(buf.base != NULL);
h.msg_namelen = sizeof(peer);
#define UV_VERSION_MAJOR 0
#define UV_VERSION_MINOR 11
-#define UV_VERSION_PATCH 6
-#define UV_VERSION_IS_RELEASE 1
+#define UV_VERSION_PATCH 7
+#define UV_VERSION_IS_RELEASE 0
#define UV_VERSION ((UV_VERSION_MAJOR << 16) | \
*/
#include <assert.h>
+#include <stdlib.h>
#include <malloc.h>
#include <direct.h>
#include <errno.h>
}
-int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file fd, void* buf,
+int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file fd, const void* buf,
size_t length, int64_t offset, uv_fs_cb cb) {
uv_fs_req_init(loop, req, UV_FS_WRITE, cb);
req->fd = fd;
- req->buf = buf;
+ req->buf = (void*) buf;
req->length = length;
req->offset = offset;
}
-int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid,
- int gid, uv_fs_cb cb) {
+int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid,
+ uv_gid_t gid, uv_fs_cb cb) {
int err;
uv_fs_req_init(loop, req, UV_FS_CHOWN, cb);
}
-int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, int uid,
- int gid, uv_fs_cb cb) {
+int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid,
+ uv_gid_t gid, uv_fs_cb cb) {
uv_fs_req_init(loop, req, UV_FS_FCHOWN, cb);
if (cb) {
#include <io.h>
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include "uv.h"
#include "internal.h"
}
buf = handle->alloc_cb((uv_handle_t*) handle, avail);
- assert(buf.len > 0);
+ if (buf.len == 0) {
+ if (handle->read2_cb) {
+ handle->read2_cb(handle, UV_ENOBUFS, buf, UV_UNKNOWN_HANDLE);
+ } else if (handle->read_cb) {
+ handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, buf);
+ }
+ break;
+ }
+ assert(buf.base != NULL);
if (ReadFile(handle->handle,
buf.base,
*/
#include <assert.h>
+#include <stdlib.h>
#include "uv.h"
#include "internal.h"
if (loop->active_tcp_streams < uv_active_tcp_streams_threshold) {
handle->flags &= ~UV_HANDLE_ZERO_READ;
handle->read_buffer = handle->alloc_cb((uv_handle_t*) handle, 65536);
- assert(handle->read_buffer.len > 0);
+ if (handle->read_buffer.len == 0) {
+ handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, buf);
+ return;
+ }
+ assert(handle->read_buffer.base != NULL);
buf = handle->read_buffer;
} else {
handle->flags |= UV_HANDLE_ZERO_READ;
int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
int* namelen) {
- uv_loop_t* loop = handle->loop;
int result;
if (!(handle->flags & UV_HANDLE_BOUND)) {
int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
int* namelen) {
- uv_loop_t* loop = handle->loop;
int result;
if (!(handle->flags & UV_HANDLE_BOUND)) {
/* Do nonblocking reads until the buffer is empty */
while (handle->flags & UV_HANDLE_READING) {
buf = handle->alloc_cb((uv_handle_t*) handle, 65536);
- assert(buf.len > 0);
+ if (buf.len == 0) {
+ handle->read_cb(handle, UV_ENOBUFS, buf);
+ break;
+ }
+ assert(buf.base != NULL);
+
flags = 0;
if (WSARecv(handle->socket,
(WSABUF*)&buf,
memset(&req->overlapped, 0, sizeof(req->overlapped));
handle->read_line_buffer = handle->alloc_cb((uv_handle_t*) handle, 8192);
+ if (handle->read_line_buffer.len == 0) {
+ handle->read_cb(handle, UV_ENOBUFS, handle->read_line_buffer);
+ return;
+ }
assert(handle->read_line_buffer.base != NULL);
- assert(handle->read_line_buffer.len > 0);
/* Duplicate the console handle, so if we want to cancel the read, we can */
/* just close this handle duplicate. */
/* Allocate a buffer if needed */
if (buf_used == 0) {
buf = handle->alloc_cb((uv_handle_t*) handle, 1024);
+ if (buf.len == 0) {
+ handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, buf);
+ goto out;
+ }
+ assert(buf.base != NULL);
}
buf.base[buf_used++] = handle->last_key[handle->last_key_offset++];
int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
int* namelen) {
- uv_loop_t* loop = handle->loop;
int result;
if (!(handle->flags & UV_HANDLE_BOUND)) {
handle->flags &= ~UV_HANDLE_ZERO_READ;
handle->recv_buffer = handle->alloc_cb((uv_handle_t*) handle, 65536);
- assert(handle->recv_buffer.len > 0);
+ if (handle->recv_buffer.len == 0) {
+ handle->recv_cb(handle, UV_ENOBUFS, handle->recv_buffer, NULL, 0);
+ return;
+ }
+ assert(handle->recv_buffer.base != NULL);
buf = handle->recv_buffer;
memset(&handle->recv_from, 0, sizeof handle->recv_from);
/* Do a nonblocking receive */
/* TODO: try to read multiple datagrams at once. FIONREAD maybe? */
buf = handle->alloc_cb((uv_handle_t*) handle, 65536);
- assert(buf.len > 0);
+ if (buf.len == 0) {
+ handle->recv_cb(handle, UV_ENOBUFS, buf, NULL, 0);
+ goto done;
+ }
+ assert(buf.base != NULL);
memset(&from, 0, sizeof from);
from_len = sizeof from;
#include "internal.h"
#include <winsock2.h>
+#include <winperf.h>
#include <iphlpapi.h>
#include <psapi.h>
#include <tlhelp32.h>
memset(uv_address, 0, sizeof *uv_address);
uv_address->name = name_buf;
+
+ if (win_address->PhysicalAddressLength == sizeof(uv_address->phys_addr)) {
+ memcpy(uv_address->phys_addr,
+ win_address->PhysicalAddress,
+ sizeof(uv_address->phys_addr));
+ }
+
uv_address->is_internal =
(win_address->IfType == IF_TYPE_SOFTWARE_LOOPBACK);
static char test_buf[] = "test-buffer\n";
-static void check_permission(const char* filename, int mode) {
+static void check_permission(const char* filename, unsigned int mode) {
int r;
uv_fs_t req;
uv_stat_t* s;
r = fstat(file, &t);
ASSERT(r == 0);
- ASSERT(s->st_dev == t.st_dev);
- ASSERT(s->st_mode == t.st_mode);
- ASSERT(s->st_nlink == t.st_nlink);
- ASSERT(s->st_uid == t.st_uid);
- ASSERT(s->st_gid == t.st_gid);
- ASSERT(s->st_rdev == t.st_rdev);
- ASSERT(s->st_ino == t.st_ino);
- ASSERT(s->st_size == t.st_size);
- ASSERT(s->st_blksize == t.st_blksize);
- ASSERT(s->st_blocks == t.st_blocks);
+ ASSERT(s->st_dev == (uint64_t) t.st_dev);
+ ASSERT(s->st_mode == (uint64_t) t.st_mode);
+ ASSERT(s->st_nlink == (uint64_t) t.st_nlink);
+ ASSERT(s->st_uid == (uint64_t) t.st_uid);
+ ASSERT(s->st_gid == (uint64_t) t.st_gid);
+ ASSERT(s->st_rdev == (uint64_t) t.st_rdev);
+ ASSERT(s->st_ino == (uint64_t) t.st_ino);
+ ASSERT(s->st_size == (uint64_t) t.st_size);
+ ASSERT(s->st_blksize == (uint64_t) t.st_blksize);
+ ASSERT(s->st_blocks == (uint64_t) t.st_blocks);
#if defined(__APPLE__)
ASSERT(s->st_atim.tv_sec == t.st_atimespec.tv_sec);
ASSERT(s->st_atim.tv_nsec == t.st_atimespec.tv_nsec);
for (i = 0; i < count; i++) {
printf(" name: %s\n", interfaces[i].name);
printf(" internal: %d\n", interfaces[i].is_internal);
+ printf(" physical address: ");
+ printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
+ (unsigned char)interfaces[i].phys_addr[0],
+ (unsigned char)interfaces[i].phys_addr[1],
+ (unsigned char)interfaces[i].phys_addr[2],
+ (unsigned char)interfaces[i].phys_addr[3],
+ (unsigned char)interfaces[i].phys_addr[4],
+ (unsigned char)interfaces[i].phys_addr[5]);
if (interfaces[i].address.address4.sin_family == AF_INET) {
uv_ip4_name(&interfaces[i].address.address4, buffer, sizeof(buffer));