From afc29ed397f71ff2ba4fa4518ab546b19123fece Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Wed, 26 Feb 2014 15:24:03 -0800 Subject: [PATCH] src: update to latest libuv api libuv gyp builds now require you to define the library disposition (static or shared). Also, libuv now supports vectored IO for file system reads and writes, update to those function signatures --- configure | 3 +++ src/node_file.cc | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 38a88c93f3..f24ac6bcc5 100755 --- a/configure +++ b/configure @@ -560,6 +560,9 @@ def configure_libuv(o): # assume shared libuv if one of these is set? if options.shared_libuv_libpath: o['libraries'] += ['-L%s' % options.shared_libuv_libpath] + else: + o['variables']['uv_library'] = 'static_library' + if options.shared_libuv_libname: o['libraries'] += ['-l%s' % options.shared_libuv_libname] elif options.shared_libuv: diff --git a/src/node_file.cc b/src/node_file.cc index 9476a1340c..c860950e34 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -769,12 +769,14 @@ static void WriteBuffer(const FunctionCallbackInfo& args) { buf += off; + uv_buf_t uvbuf = uv_buf_init(const_cast(buf), len); + if (cb->IsFunction()) { - ASYNC_CALL(write, cb, fd, buf, len, pos) + ASYNC_CALL(write, cb, fd, &uvbuf, 1, pos) return; } - SYNC_CALL(write, NULL, fd, buf, len, pos) + SYNC_CALL(write, NULL, fd, &uvbuf, 1, pos) args.GetReturnValue().Set(SYNC_RESULT); } @@ -818,8 +820,10 @@ static void WriteString(const FunctionCallbackInfo& args) { pos = GET_OFFSET(args[2]); cb = args[4]; + uv_buf_t uvbuf = uv_buf_init(const_cast(buf), len); + if (!cb->IsFunction()) { - SYNC_CALL(write, NULL, fd, buf, len, pos) + SYNC_CALL(write, NULL, fd, &uvbuf, 1, pos) if (must_free) delete[] buf; return args.GetReturnValue().Set(SYNC_RESULT); @@ -829,8 +833,8 @@ static void WriteString(const FunctionCallbackInfo& args) { int err = uv_fs_write(env->event_loop(), &req_wrap->req_, fd, - buf, - len, + &uvbuf, + 1, pos, After); req_wrap->object()->Set(env->oncomplete_string(), cb); @@ -896,12 +900,14 @@ static void Read(const FunctionCallbackInfo& args) { buf = buffer_data + off; + uv_buf_t uvbuf = uv_buf_init(const_cast(buf), len); + cb = args[5]; if (cb->IsFunction()) { - ASYNC_CALL(read, cb, fd, buf, len, pos); + ASYNC_CALL(read, cb, fd, &uvbuf, 1, pos); } else { - SYNC_CALL(read, 0, fd, buf, len, pos) + SYNC_CALL(read, 0, fd, &uvbuf, 1, pos) args.GetReturnValue().Set(SYNC_RESULT); } }