Showing with 181 additions and 208 deletions.
  1. +1 −0 include/uv-private/uv-unix.h
  2. +46 −27 src/unix/fs.c
  3. +2 −1 src/unix/getaddrinfo.c
  4. +2 −1 src/unix/internal.h
  5. +122 −119 src/unix/threadpool.c
  6. +7 −59 test/benchmark-fs-stat.c
  7. +1 −1 test/runner.c
@@ -62,6 +62,7 @@ struct uv__work {
void (*work)(struct uv__work *w);
void (*done)(struct uv__work *w, int status);
struct uv_loop_s* loop;
void* thread_ctx;
ngx_queue_t wq;
};

@@ -82,14 +82,15 @@
} \
while (0)

#define POST \
#define POST(hint) \
do { \
if ((cb) != NULL) { \
uv__work_submit((loop), \
&(req)->work_req, \
uv__fs_work, \
uv__fs_done, \
UV__THREADPOOL_IO); \
UV__THREADPOOL_IO, \
(hint)); \
return 0; \
} \
else { \
@@ -587,6 +588,24 @@ static void uv__fs_done(struct uv__work* w, int status) {
}


/* Jenkins hash. */
static long hash(const char* s) {
long h;

for (h = 0; *s != '\0'; s++) {
h += *s;
h += h << 10;
h ^= h >> 6;
}

h += h << 3;
h ^= h >> 1;
h += h << 15;

return h;
}


int uv_fs_chmod(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
@@ -595,7 +614,7 @@ int uv_fs_chmod(uv_loop_t* loop,
INIT(CHMOD);
PATH;
req->mode = mode;
POST;
POST(hash(path));
}


@@ -609,14 +628,14 @@ int uv_fs_chown(uv_loop_t* loop,
PATH;
req->uid = uid;
req->gid = gid;
POST;
POST(hash(path));
}


int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
INIT(CLOSE);
req->file = file;
POST;
POST(file);
}


@@ -628,7 +647,7 @@ int uv_fs_fchmod(uv_loop_t* loop,
INIT(FCHMOD);
req->file = file;
req->mode = mode;
POST;
POST(file);
}


@@ -642,28 +661,28 @@ int uv_fs_fchown(uv_loop_t* loop,
req->file = file;
req->uid = uid;
req->gid = gid;
POST;
POST(file);
}


int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
INIT(FDATASYNC);
req->file = file;
POST;
POST(file);
}


int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
INIT(FSTAT);
req->file = file;
POST;
POST(file);
}


int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
INIT(FSYNC);
req->file = file;
POST;
POST(file);
}


@@ -675,7 +694,7 @@ int uv_fs_ftruncate(uv_loop_t* loop,
INIT(FTRUNCATE);
req->file = file;
req->off = off;
POST;
POST(file);
}


@@ -689,14 +708,14 @@ int uv_fs_futime(uv_loop_t* loop,
req->file = file;
req->atime = atime;
req->mtime = mtime;
POST;
POST(file);
}


int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(LSTAT);
PATH;
POST;
POST(hash(path));
}


@@ -707,7 +726,7 @@ int uv_fs_link(uv_loop_t* loop,
uv_fs_cb cb) {
INIT(LINK);
PATH2;
POST;
POST(hash(path)); /* TODO Take both path and new_path in account. */
}


@@ -719,7 +738,7 @@ int uv_fs_mkdir(uv_loop_t* loop,
INIT(MKDIR);
PATH;
req->mode = mode;
POST;
POST(hash(path));
}


@@ -733,7 +752,7 @@ int uv_fs_open(uv_loop_t* loop,
PATH;
req->flags = flags;
req->mode = mode;
POST;
POST(hash(path));
}


@@ -748,7 +767,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
req->buf = buf;
req->len = len;
req->off = off;
POST;
POST(file);
}


@@ -760,7 +779,7 @@ int uv_fs_readdir(uv_loop_t* loop,
INIT(READDIR);
PATH;
req->flags = flags;
POST;
POST(hash(path));
}


@@ -770,7 +789,7 @@ int uv_fs_readlink(uv_loop_t* loop,
uv_fs_cb cb) {
INIT(READLINK);
PATH;
POST;
POST(hash(path));
}


@@ -781,14 +800,14 @@ int uv_fs_rename(uv_loop_t* loop,
uv_fs_cb cb) {
INIT(RENAME);
PATH2;
POST;
POST(hash(path)); /* TODO Take both path and new_path in account. */
}


int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(RMDIR);
PATH;
POST;
POST(hash(path));
}


@@ -804,14 +823,14 @@ int uv_fs_sendfile(uv_loop_t* loop,
req->file = out_fd;
req->off = off;
req->len = len;
POST;
POST(in_fd); /* TODO Take both in_fd and out_fd in account. */
}


int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(STAT);
PATH;
POST;
POST(hash(path));
}


@@ -824,14 +843,14 @@ int uv_fs_symlink(uv_loop_t* loop,
INIT(SYMLINK);
PATH2;
req->flags = flags;
POST;
POST(hash(path)); /* TODO Take both path and new_path in account. */
}


int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(UNLINK);
PATH;
POST;
POST(hash(path));
}


@@ -845,7 +864,7 @@ int uv_fs_utime(uv_loop_t* loop,
PATH;
req->atime = atime;
req->mtime = mtime;
POST;
POST(hash(path));
}


@@ -861,7 +880,7 @@ int uv_fs_write(uv_loop_t* loop,
req->buf = buf;
req->len = len;
req->off = off;
POST;
POST(file);
}


@@ -148,7 +148,8 @@ int uv_getaddrinfo(uv_loop_t* loop,
&req->work_req,
uv__getaddrinfo_work,
uv__getaddrinfo_done,
UV__THREADPOOL_IO);
UV__THREADPOOL_IO,
-1);

return 0;
}
@@ -181,7 +181,8 @@ void uv__work_submit(uv_loop_t* loop,
struct uv__work *w,
void (*work)(struct uv__work *w),
void (*done)(struct uv__work *w, int status),
unsigned int type);
unsigned int type,
long hint);
void uv__work_done(uv_async_t* handle, int status);

/* platform specific */