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

uv: upgrade to 61a6e06e

  • Loading branch information...
indutny committed Jun 18, 2012
1 parent 30ab1f5 commit 057b80611f977789f6c1334fdf3680c105af364e
View
@@ -37,8 +37,8 @@ RUNNER_LINKFLAGS=$(LINKFLAGS)
RUNNER_LIBS=-lws2_32 -lpsapi -liphlpapi
RUNNER_SRC=test/runner-win.c
-uv.a: $(WIN_OBJS) src/cares.o src/uv-common.o $(CARES_OBJS)
- $(AR) rcs uv.a $(WIN_OBJS) src/cares.o src/uv-common.o $(CARES_OBJS)
+uv.a: $(WIN_OBJS) src/cares.o src/fs-poll.o src/uv-common.o $(CARES_OBJS)
+ $(AR) rcs uv.a $^
src/%.o: src/%.c include/uv.h include/uv-private/uv-win.h
$(CC) $(CFLAGS) -c $< -o $@
View
@@ -129,8 +129,8 @@ endif
RUNNER_LIBS=
RUNNER_SRC=test/runner-unix.c
-uv.a: $(OBJS) src/cares.o src/uv-common.o src/unix/ev/ev.o src/unix/uv-eio.o src/unix/eio/eio.o $(CARES_OBJS)
- $(AR) rcs uv.a $(OBJS) src/cares.o src/uv-common.o src/unix/uv-eio.o src/unix/ev/ev.o src/unix/eio/eio.o $(CARES_OBJS)
+uv.a: $(OBJS) src/cares.o src/fs-poll.o src/uv-common.o src/unix/ev/ev.o src/unix/uv-eio.o src/unix/eio/eio.o $(CARES_OBJS)
+ $(AR) rcs uv.a $^
src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
@@ -28,13 +28,17 @@
#include "eio.h"
#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
-#include <pwd.h>
+
#include <termios.h>
+#include <pwd.h>
#include <semaphore.h>
#include <pthread.h>
@@ -55,6 +59,8 @@ typedef int uv_file;
typedef int uv_os_sock_t;
+typedef struct stat uv_statbuf_t;
+
#define UV_ONCE_INIT PTHREAD_ONCE_INIT
typedef pthread_once_t uv_once_t;
@@ -165,6 +165,8 @@ typedef struct uv_buf_t {
typedef int uv_file;
+typedef struct _stati64 uv_statbuf_t;
+
typedef SOCKET uv_os_sock_t;
typedef HANDLE uv_thread_t;
View
@@ -140,6 +140,7 @@ typedef enum {
XX(ASYNC, async) \
XX(CHECK, check) \
XX(FS_EVENT, fs_event) \
+ XX(FS_POLL, fs_poll) \
XX(IDLE, idle) \
XX(NAMED_PIPE, pipe) \
XX(POLL, poll) \
@@ -209,6 +210,7 @@ typedef struct uv_udp_send_s uv_udp_send_t;
typedef struct uv_fs_s uv_fs_t;
/* uv_fs_event_t is a subclass of uv_handle_t. */
typedef struct uv_fs_event_s uv_fs_event_t;
+typedef struct uv_fs_poll_s uv_fs_poll_t;
typedef struct uv_work_s uv_work_t;
@@ -312,6 +314,11 @@ typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg);
typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename,
int events, int status);
+typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle,
+ int status,
+ uv_statbuf_t* prev,
+ uv_statbuf_t* curr);
+
typedef enum {
UV_LEAVE_GROUP = 0,
UV_JOIN_GROUP
@@ -1510,6 +1517,46 @@ struct uv_fs_event_s {
};
+/*
+ * uv_fs_stat() based polling file watcher.
+ */
+struct uv_fs_poll_s {
+ UV_HANDLE_FIELDS
+ /* Private, don't touch. */
+ int busy_polling; /* TODO(bnoordhuis) Fold into flags field. */
+ unsigned int interval;
+ uint64_t start_time;
+ char* path;
+ uv_fs_poll_cb poll_cb;
+ uv_timer_t timer_handle;
+ uv_fs_t* fs_req;
+ uv_statbuf_t statbuf;
+};
+
+UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
+
+/*
+ * Check the file at `path` for changes every `interval` milliseconds.
+ *
+ * Your callback i invoked with `status == -1` if `path` does not exist
+ * or is inaccessible. The watcher is *not* stopped but your callback is
+ * not called again until something changes (e.g. when the file is created
+ * or the error reason changes).
+ *
+ * When `status == 0`, your callback receives pointers to the old and new
+ * `uv_statbuf_t` structs. They are valid for the duration of the callback
+ * only!
+ *
+ * For maximum portability, use multi-second intervals. Sub-second intervals
+ * will not detect all changes on many file systems.
+ */
+UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
+ uv_fs_poll_cb poll_cb,
+ const char* path,
+ unsigned int interval);
+
+UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
+
/*
* Gets load avg
* See: http://en.wikipedia.org/wiki/Load_(computing)
@@ -1683,22 +1730,23 @@ union uv_any_req {
struct uv_counters_s {
+ uint64_t async_init;
+ uint64_t check_init;
uint64_t eio_init;
- uint64_t req_init;
+ uint64_t fs_event_init;
+ uint64_t fs_poll_init;
uint64_t handle_init;
- uint64_t stream_init;
- uint64_t tcp_init;
- uint64_t udp_init;
+ uint64_t idle_init;
uint64_t pipe_init;
- uint64_t tty_init;
uint64_t poll_init;
uint64_t prepare_init;
- uint64_t check_init;
- uint64_t idle_init;
- uint64_t async_init;
- uint64_t timer_init;
uint64_t process_init;
- uint64_t fs_event_init;
+ uint64_t req_init;
+ uint64_t stream_init;
+ uint64_t tcp_init;
+ uint64_t timer_init;
+ uint64_t tty_init;
+ uint64_t udp_init;
};
Oops, something went wrong.

0 comments on commit 057b806

Please sign in to comment.