diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2012-01-12 02:17:44 +0600 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2012-01-12 02:17:44 +0600 |
commit | 9e6957b0a55e7ef8cd2a2efc066555da8d781355 (patch) | |
tree | 4e9835aca02883f3303623dd6c80cb55231cdc3e | |
parent | 8abb73ef58ccb6fd1b8cc4266c9981ce6574c78f (diff) | |
parent | 07701e7cc85feaeaa0a2a6c8146b0cb3eefc12fe (diff) | |
download | android-node-v8-9e6957b0a55e7ef8cd2a2efc066555da8d781355.tar.gz android-node-v8-9e6957b0a55e7ef8cd2a2efc066555da8d781355.tar.bz2 android-node-v8-9e6957b0a55e7ef8cd2a2efc066555da8d781355.zip |
Merge branch 'v0.6'
Conflicts:
src/handle_wrap.cc
src/node_zlib.cc
src/process_wrap.cc
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | doc/full-white-stripe.bmp | bin | 461814 -> 0 bytes | |||
-rw-r--r-- | doc/full-white-stripe.jpg | bin | 0 -> 4383 bytes | |||
-rw-r--r-- | doc/thin-white-stripe.bmp | bin | 85894 -> 0 bytes | |||
-rw-r--r-- | doc/thin-white-stripe.jpg | bin | 0 -> 3316 bytes | |||
-rw-r--r-- | src/handle_wrap.cc | 6 | ||||
-rw-r--r-- | src/node_zlib.cc | 80 | ||||
-rw-r--r-- | src/process_wrap.cc | 14 | ||||
-rw-r--r-- | src/stream_wrap.cc | 15 | ||||
-rw-r--r-- | tools/msvs/msi/product.wxs | 4 |
10 files changed, 61 insertions, 60 deletions
@@ -177,7 +177,7 @@ bench-idle: ./node benchmark/idle_clients.js & jslint: - PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ -r test/ + PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js cpplint: @$(PYTHON) tools/cpplint.py $(wildcard src/*.cc src/*.h src/*.c) diff --git a/doc/full-white-stripe.bmp b/doc/full-white-stripe.bmp Binary files differdeleted file mode 100644 index bb2bf9c493..0000000000 --- a/doc/full-white-stripe.bmp +++ /dev/null diff --git a/doc/full-white-stripe.jpg b/doc/full-white-stripe.jpg Binary files differnew file mode 100644 index 0000000000..9b990aeff7 --- /dev/null +++ b/doc/full-white-stripe.jpg diff --git a/doc/thin-white-stripe.bmp b/doc/thin-white-stripe.bmp Binary files differdeleted file mode 100644 index 8130a843c4..0000000000 --- a/doc/thin-white-stripe.bmp +++ /dev/null diff --git a/doc/thin-white-stripe.jpg b/doc/thin-white-stripe.jpg Binary files differnew file mode 100644 index 0000000000..8dc3d4ae8f --- /dev/null +++ b/doc/thin-white-stripe.jpg diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index f661885d9f..0eb8281ff9 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -100,8 +100,11 @@ Handle<Value> HandleWrap::Close(const Arguments& args) { UNWRAP + // guard against uninitialized handle or double close + if (wrap->handle__ == NULL) return v8::Null(); assert(!wrap->object_.IsEmpty()); uv_close(wrap->handle__, OnClose); + wrap->handle__ = NULL; HandleWrap::Ref(args); @@ -143,6 +146,9 @@ void HandleWrap::OnClose(uv_handle_t* handle) { // The wrap object should still be there. assert(wrap->object_.IsEmpty() == false); + // But the handle pointer should be gone. + assert(wrap->handle__ == NULL); + wrap->object_->SetPointerInInternalField(0, NULL); wrap->object_.Dispose(); wrap->object_.Clear(); diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 228427b640..a597ffabe8 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -30,9 +30,6 @@ #include <node.h> #include <node_buffer.h> #include <node_vars.h> -#include <req_wrap.h> - -#include <node_vars.h> // We do the following to minimize the detal between v0.6 branch. We want to // use the variables as they were being used before. #define callback_sym NODE_VAR(callback_sym) @@ -41,8 +38,6 @@ namespace node { using namespace v8; -// write() returns one of these, and then calls the cb() when it's done. -typedef ReqWrap<uv_work_t> WorkReqWrap; enum node_zlib_mode { DEFLATE = 1, @@ -81,14 +76,16 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { } // write(flush, in, in_off, in_len, out, out_off, out_len) - static Handle<Value> - Write(const Arguments& args) { + static Handle<Value> Write(const Arguments& args) { HandleScope scope; assert(args.Length() == 7); ZCtx<mode> *ctx = ObjectWrap::Unwrap< ZCtx<mode> >(args.This()); assert(ctx->init_done_ && "write before init"); + assert(!ctx->write_in_progress_ && "write already in progress"); + ctx->write_in_progress_ = true; + unsigned int flush = args[0]->Uint32Value(); Bytef *in; Bytef *out; @@ -104,8 +101,8 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { assert(Buffer::HasInstance(args[1])); Local<Object> in_buf; in_buf = args[1]->ToObject(); - in_off = (size_t)args[2]->Uint32Value(); - in_len = (size_t)args[3]->Uint32Value(); + in_off = args[2]->Uint32Value(); + in_len = args[3]->Uint32Value(); assert(in_off + in_len <= Buffer::Length(in_buf)); in = reinterpret_cast<Bytef *>(Buffer::Data(in_buf) + in_off); @@ -113,16 +110,16 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { assert(Buffer::HasInstance(args[4])); Local<Object> out_buf = args[4]->ToObject(); - out_off = (size_t)args[5]->Uint32Value(); - out_len = (size_t)args[6]->Uint32Value(); + out_off = args[5]->Uint32Value(); + out_len = args[6]->Uint32Value(); assert(out_off + out_len <= Buffer::Length(out_buf)); out = reinterpret_cast<Bytef *>(Buffer::Data(out_buf) + out_off); - WorkReqWrap *req_wrap = new WorkReqWrap(); + // build up the work request + uv_work_t* work_req = &(ctx->work_req_); - req_wrap->data_ = ctx; ctx->strm_.avail_in = in_len; - ctx->strm_.next_in = &(*in); + ctx->strm_.next_in = in; ctx->strm_.avail_out = out_len; ctx->strm_.next_out = out; ctx->flush_ = flush; @@ -130,18 +127,14 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { // set this so that later on, I can easily tell how much was written. ctx->chunk_size_ = out_len; - // build up the work request - uv_work_t* work_req = new uv_work_t(); - work_req->data = req_wrap; - uv_queue_work(Loop(), work_req, ZCtx<mode>::Process, ZCtx<mode>::After); - req_wrap->Dispatched(); + ctx->Ref(); - return req_wrap->object_; + return ctx->handle_; } @@ -149,10 +142,8 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { // This function may be called multiple times on the uv_work pool // for a single write() call, until all of the input bytes have // been consumed. - static void - Process(uv_work_t* work_req) { - WorkReqWrap *req_wrap = reinterpret_cast<WorkReqWrap *>(work_req->data); - ZCtx<mode> *ctx = (ZCtx<mode> *)req_wrap->data_; + static void Process(uv_work_t* work_req) { + ZCtx<mode> *ctx = container_of(work_req, ZCtx<mode>, work_req_); // If the avail_out is left at 0, then it means that it ran out // of room. If there was avail_out left over, then it means @@ -162,13 +153,13 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { case DEFLATE: case GZIP: case DEFLATERAW: - err = deflate(&(ctx->strm_), ctx->flush_); + err = deflate(&ctx->strm_, ctx->flush_); break; case UNZIP: case INFLATE: case GUNZIP: case INFLATERAW: - err = inflate(&(ctx->strm_), ctx->flush_); + err = inflate(&ctx->strm_, ctx->flush_); // If data was encoded with dictionary if (err == Z_NEED_DICT) { @@ -197,26 +188,25 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { } // v8 land! - static void - After(uv_work_t* work_req) { + static void After(uv_work_t* work_req) { HandleScope scope; - WorkReqWrap *req_wrap = reinterpret_cast<WorkReqWrap *>(work_req->data); - ZCtx<mode> *ctx = (ZCtx<mode> *)req_wrap->data_; + ZCtx<mode> *ctx = container_of(work_req, ZCtx<mode>, work_req_); + Local<Integer> avail_out = Integer::New(ctx->strm_.avail_out); Local<Integer> avail_in = Integer::New(ctx->strm_.avail_in); + ctx->write_in_progress_ = false; + // call the write() cb - assert(req_wrap->object_->Get(callback_sym)->IsFunction() && + assert(ctx->handle_->Get(callback_sym)->IsFunction() && "Invalid callback"); Local<Value> args[2] = { avail_in, avail_out }; - MakeCallback(req_wrap->object_, "callback", 2, args); + MakeCallback(ctx->handle_, "callback", 2, args); - // delete the ReqWrap - delete req_wrap; + ctx->Unref(); } - static Handle<Value> - New(const Arguments& args) { + static Handle<Value> New(const Arguments& args) { HandleScope scope; ZCtx<mode> *ctx = new ZCtx<mode>(); ctx->Wrap(args.This()); @@ -224,8 +214,7 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { } // just pull the ints out of the args and call the other Init - static Handle<Value> - Init(const Arguments& args) { + static Handle<Value> Init(const Arguments& args) { HandleScope scope; assert((args.Length() == 4 || args.Length() == 5) && @@ -265,14 +254,8 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { return Undefined(); } - static void - Init(ZCtx *ctx, - int level, - int windowBits, - int memLevel, - int strategy, - char* dictionary, - size_t dictionary_len) { + static void Init(ZCtx *ctx, int level, int windowBits, int memLevel, + int strategy, char* dictionary, size_t dictionary_len) { ctx->level_ = level; ctx->windowBits_ = windowBits; ctx->memLevel_ = memLevel; @@ -340,6 +323,7 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { assert(err == Z_OK && "Failed to set dictionary"); } + ctx->write_in_progress_ = false; ctx->init_done_ = true; } @@ -359,6 +343,10 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap { int flush_; int chunk_size_; + + bool write_in_progress_; + + uv_work_t work_req_; }; diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 847a76352f..5c4282ffb0 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -178,10 +178,14 @@ class ProcessWrap : public HandleWrap { int r = uv_spawn(Loop(), &wrap->process_, options); - wrap->SetHandle((uv_handle_t*)&wrap->process_); - assert(wrap->process_.data == wrap); - - wrap->object_->Set(String::New("pid"), Integer::New(wrap->process_.pid)); + if (r) { + SetErrno(uv_last_error(Loop())); + } + else { + wrap->SetHandle((uv_handle_t*)&wrap->process_); + assert(wrap->process_.data == wrap); + wrap->object_->Set(String::New("pid"), Integer::New(wrap->process_.pid)); + } if (options.args) { for (int i = 0; options.args[i]; i++) free(options.args[i]); @@ -196,8 +200,6 @@ class ProcessWrap : public HandleWrap { delete [] options.env; } - if (r) SetErrno(uv_last_error(Loop())); - return scope.Close(Integer::New(r)); } diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index a64b4c356c..37eb592522 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -35,6 +35,7 @@ #define slab_sym NODE_VAR(slab_sym) #define handle_that_last_alloced NODE_VAR(handle_that_last_alloced) #define buffer_sym NODE_VAR(buffer_sym) +#define buffer_constructor_template NODE_VAR(buffer_constructor_template) #define write_queue_size_sym NODE_VAR(write_queue_size_sym) #define stream_wrap_initialized NODE_VAR(stream_wrap_initialized) @@ -153,13 +154,17 @@ Handle<Value> StreamWrap::ReadStop(const Arguments& args) { } -inline char* StreamWrap::NewSlab(Handle<Object> global, - Handle<Object> wrap_obj) { - Buffer* b = Buffer::New(SLAB_SIZE); - global->SetHiddenValue(slab_sym, b->handle_); +char* StreamWrap::NewSlab(Handle<Object> global, + Handle<Object> wrap_obj) { + HandleScope scope; + Local<Value> arg = Integer::NewFromUnsigned(SLAB_SIZE); + Local<Object> b = buffer_constructor_template->GetFunction()-> + NewInstance(1, &arg); + if (b.IsEmpty()) return NULL; + global->SetHiddenValue(slab_sym, b); assert(Buffer::Length(b) == SLAB_SIZE); slab_used = 0; - wrap_obj->SetHiddenValue(slab_sym, b->handle_); + wrap_obj->SetHiddenValue(slab_sym, b); return Buffer::Data(b); } diff --git a/tools/msvs/msi/product.wxs b/tools/msvs/msi/product.wxs index bdf28a587a..1d445d272a 100644 --- a/tools/msvs/msi/product.wxs +++ b/tools/msvs/msi/product.wxs @@ -114,8 +114,8 @@ </UI> <UIRef Id="WixUI_Common" /> - <WixVariable Id="WixUIBannerBmp" Value="..\..\..\doc\thin-white-stripe.bmp" /> - <WixVariable Id="WixUIDialogBmp" Value="..\..\..\doc\full-white-stripe.bmp" /> + <WixVariable Id="WixUIBannerBmp" Value="..\..\..\doc\thin-white-stripe.jpg" /> + <WixVariable Id="WixUIDialogBmp" Value="..\..\..\doc\full-white-stripe.jpg" /> </Product> </Wix> |