This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

uv: upgrade to 1cca230

  • Loading branch information...
bnoordhuis committed Jan 23, 2012
1 parent ff51263 commit 2433eeb3850a91feb99bab530cb7183800166390
View
@@ -153,7 +153,6 @@
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
- 'MACOSX_DEPLOYMENT_TARGET': '10.4', # -mmacosx-version-min=10.4
'PREBINDING': 'NO', # No -Wl,-prebind
'USE_HEADERMAP': 'NO',
'OTHER_CFLAGS': [
View
@@ -45,12 +45,12 @@ if __name__ == '__main__':
# There's a bug with windows which doesn't allow this feature.
if sys.platform != 'win32':
-
# Tell gyp to write the Makefiles into output_dir
args.extend(['--generator-output', output_dir])
-
# Tell make to write its output into the same dir
args.extend(['-Goutput_dir=' + output_dir])
+ # Create Makefiles, not XCode projects
+ args.extend('-f make'.split())
args.append('-Dtarget_arch=ia32')
args.append('-Dcomponent=static_library')
View
@@ -653,6 +653,32 @@ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
const char* multicast_addr, const char* interface_addr,
uv_membership membership);
+/*
+ * Set the multicast ttl
+ *
+ * Arguments:
+ * handle UDP handle. Should have been initialized with
+ * `uv_udp_init`.
+ * ttl 1 through 255
+ *
+ * Returns:
+ * 0 on success, -1 on error.
+ */
+int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
+
+/*
+ * Set broadcast on or off
+ *
+ * Arguments:
+ * handle UDP handle. Should have been initialized with
+ * `uv_udp_init`.
+ * on 1 for on, 0 for off
+ *
+ * Returns:
+ * 0 on success, -1 on error.
+ */
+int uv_udp_set_broadcast(uv_udp_t* handle, int on);
+
/*
* Send data. If the socket has not previously been bound with `uv_udp_bind`
* or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
View
@@ -64,7 +64,6 @@ static void uv__finish_close(uv_handle_t* handle);
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
- uv_udp_t* udp;
uv_async_t* async;
uv_timer_t* timer;
uv_stream_t* stream;
@@ -97,11 +96,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
break;
case UV_UDP:
- udp = (uv_udp_t*)handle;
- uv__udp_watcher_stop(udp, &udp->read_watcher);
- uv__udp_watcher_stop(udp, &udp->write_watcher);
- uv__close(udp->fd);
- udp->fd = -1;
+ uv__udp_start_close((uv_udp_t*)handle);
break;
case UV_PREPARE:
@@ -234,7 +229,6 @@ void uv__handle_init(uv_loop_t* loop, uv_handle_t* handle,
handle->flags = 0;
ev_init(&handle->next_watcher, uv__next);
- handle->next_watcher.data = handle;
/* Ref the loop until this handle is closed. See uv__finish_close. */
ev_ref(loop->ev);
@@ -279,10 +273,7 @@ void uv__finish_close(uv_handle_t* handle) {
break;
case UV_UDP:
- assert(!ev_is_active(&((uv_udp_t*)handle)->read_watcher));
- assert(!ev_is_active(&((uv_udp_t*)handle)->write_watcher));
- assert(((uv_udp_t*)handle)->fd == -1);
- uv__udp_destroy((uv_udp_t*)handle);
+ uv__udp_finish_close((uv_udp_t*)handle);
break;
case UV_PROCESS:
@@ -307,9 +298,9 @@ void uv__finish_close(uv_handle_t* handle) {
}
-void uv__next(EV_P_ ev_idle* watcher, int revents) {
- uv_handle_t* handle = watcher->data;
- assert(watcher == &handle->next_watcher);
+void uv__next(EV_P_ ev_idle* w, int revents) {
+ uv_handle_t* handle = container_of(w, uv_handle_t, next_watcher);
+
assert(revents == EV_IDLE);
/* For now this function is only to handle the closing event, but we might
@@ -347,7 +338,7 @@ void uv__req_init(uv_loop_t* loop, uv_req_t* req) {
static void uv__prepare(EV_P_ ev_prepare* w, int revents) {
- uv_prepare_t* prepare = w->data;
+ uv_prepare_t* prepare = container_of(w, uv_prepare_t, prepare_watcher);
if (prepare->prepare_cb) {
prepare->prepare_cb(prepare, 0);
@@ -360,8 +351,6 @@ int uv_prepare_init(uv_loop_t* loop, uv_prepare_t* prepare) {
loop->counters.prepare_init++;
ev_prepare_init(&prepare->prepare_watcher, uv__prepare);
- prepare->prepare_watcher.data = prepare;
-
prepare->prepare_cb = NULL;
return 0;
@@ -397,7 +386,7 @@ int uv_prepare_stop(uv_prepare_t* prepare) {
static void uv__check(EV_P_ ev_check* w, int revents) {
- uv_check_t* check = w->data;
+ uv_check_t* check = container_of(w, uv_check_t, check_watcher);
if (check->check_cb) {
check->check_cb(check, 0);
@@ -410,8 +399,6 @@ int uv_check_init(uv_loop_t* loop, uv_check_t* check) {
loop->counters.check_init++;
ev_check_init(&check->check_watcher, uv__check);
- check->check_watcher.data = check;
-
check->check_cb = NULL;
return 0;
@@ -447,7 +434,7 @@ int uv_check_stop(uv_check_t* check) {
static void uv__idle(EV_P_ ev_idle* w, int revents) {
- uv_idle_t* idle = (uv_idle_t*)(w->data);
+ uv_idle_t* idle = container_of(w, uv_idle_t, idle_watcher);
if (idle->idle_cb) {
idle->idle_cb(idle, 0);
@@ -461,8 +448,6 @@ int uv_idle_init(uv_loop_t* loop, uv_idle_t* idle) {
loop->counters.idle_init++;
ev_idle_init(&idle->idle_watcher, uv__idle);
- idle->idle_watcher.data = idle;
-
idle->idle_cb = NULL;
return 0;
@@ -517,7 +502,7 @@ int uv_is_active(uv_handle_t* handle) {
static void uv__async(EV_P_ ev_async* w, int revents) {
- uv_async_t* async = w->data;
+ uv_async_t* async = container_of(w, uv_async_t, async_watcher);
if (async->async_cb) {
async->async_cb(async, 0);
@@ -530,8 +515,6 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb) {
loop->counters.async_init++;
ev_async_init(&async->async_watcher, uv__async);
- async->async_watcher.data = async;
-
async->async_cb = async_cb;
/* Note: This does not have symmetry with the other libev wrappers. */
@@ -549,7 +532,7 @@ int uv_async_send(uv_async_t* async) {
static void uv__timer_cb(EV_P_ ev_timer* w, int revents) {
- uv_timer_t* timer = w->data;
+ uv_timer_t* timer = container_of(w, uv_timer_t, timer_watcher);
if (!ev_is_active(w)) {
ev_ref(EV_A);
@@ -566,7 +549,6 @@ int uv_timer_init(uv_loop_t* loop, uv_timer_t* timer) {
loop->counters.timer_init++;
ev_init(&timer->timer_watcher, uv__timer_cb);
- timer->timer_watcher.data = timer;
return 0;
}
@@ -790,23 +772,6 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
}
-int uv__close(int fd) {
- int status;
-
- /*
- * Retry on EINTR. You may think this is academic but on linux
- * and probably other Unices too, close(2) is interruptible.
- * Failing to handle EINTR is a common source of fd leaks.
- */
- do {
- status = close(fd);
- }
- while (status == -1 && errno == EINTR);
-
- return status;
-}
-
-
int uv__nonblock(int fd, int set) {
#if FIONBIO
return ioctl(fd, FIONBIO, &set);
@@ -200,8 +200,6 @@ kqueue_destroy (EV_P)
void inline_size
kqueue_fork (EV_P)
{
- close (backend_fd);
-
while ((backend_fd = kqueue ()) < 0)
ev_syserr ("(libev) kqueue");
@@ -154,14 +154,19 @@ enum {
UV_TCP_KEEPALIVE = 0x100 /* Turn on keep-alive. */
};
-int uv__close(int fd);
+/* core */
void uv__handle_init(uv_loop_t* loop, uv_handle_t* handle, uv_handle_type type);
-
-
int uv__nonblock(int fd, int set) __attribute__((unused));
int uv__cloexec(int fd, int set) __attribute__((unused));
int uv__socket(int domain, int type, int protocol);
+/* We used to handle EINTR in uv__close() but linux 2.6 will have closed the
+ * file descriptor anyway, even on EINTR. Retrying in that case isn't merely
+ * useless, it's actively harmful - the file descriptor may have been acquired
+ * by another thread.
+ */
+#define uv__close(fd) close(fd)
+
/* error */
uv_err_code uv_translate_sys_error(int sys_errno);
void uv_fatal_error(const int errorno, const char* syscall);
@@ -191,8 +196,8 @@ void uv__pipe_accept(EV_P_ ev_io* watcher, int revents);
int uv_pipe_cleanup(uv_pipe_t* handle);
/* udp */
-void uv__udp_destroy(uv_udp_t* handle);
-void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w);
+void uv__udp_start_close(uv_udp_t* handle);
+void uv__udp_finish_close(uv_udp_t* handle);
/* fs */
void uv__fs_event_destroy(uv_fs_event_t* handle);
View
@@ -120,17 +120,15 @@ uv_handle_type uv_guess_handle(uv_file file) {
struct stat s;
if (file < 0) {
- uv__set_sys_error(NULL, EINVAL); /* XXX Need loop? */
- return -1;
+ return UV_UNKNOWN_HANDLE;
}
if (isatty(file)) {
return UV_TTY;
}
if (fstat(file, &s)) {
- uv__set_sys_error(NULL, errno); /* XXX Need loop? */
- return -1;
+ return UV_UNKNOWN_HANDLE;
}
if (!S_ISSOCK(s.st_mode) && !S_ISFIFO(s.st_mode)) {
Oops, something went wrong.

0 comments on commit 2433eeb

Please sign in to comment.