summaryrefslogtreecommitdiff
path: root/src/stream_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-11-12 16:25:07 +0100
committerFedor Indutny <fedor@indutny.com>2014-11-18 22:56:10 +0300
commit83d2cb634e15546d50f135f1761ff19414b364c3 (patch)
tree7b488c2c04137f69797bed8feed8892e092a866f /src/stream_wrap.cc
parent8ba39b01899fd51554fbfb5c906e88adf5b0035c (diff)
downloadandroid-node-v8-83d2cb634e15546d50f135f1761ff19414b364c3.tar.gz
android-node-v8-83d2cb634e15546d50f135f1761ff19414b364c3.tar.bz2
android-node-v8-83d2cb634e15546d50f135f1761ff19414b364c3.zip
src: remove static variables from tls_wrap
Remove the error message globals. More prep work for multi-isolate support. Reviewed-By: Fedor Indutny <fedor@indutny.com> PR-URL: https://github.com/node-forward/node/pull/58
Diffstat (limited to 'src/stream_wrap.cc')
-rw-r--r--src/stream_wrap.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc
index 103d1e3038..f39739cd2f 100644
--- a/src/stream_wrap.cc
+++ b/src/stream_wrap.cc
@@ -233,8 +233,10 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
done:
const char* msg = wrap->callbacks()->Error();
- if (msg != nullptr)
+ if (msg != nullptr) {
req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg));
+ wrap->callbacks()->ClearError();
+ }
req_wrap_obj->Set(env->bytes_string(),
Integer::NewFromUnsigned(env->isolate(), length));
args.GetReturnValue().Set(err);
@@ -364,8 +366,10 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
done:
const char* msg = wrap->callbacks()->Error();
- if (msg != nullptr)
+ if (msg != nullptr) {
req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg));
+ wrap->callbacks()->ClearError();
+ }
req_wrap_obj->Set(env->bytes_string(),
Integer::NewFromUnsigned(env->isolate(), data_size));
args.GetReturnValue().Set(err);
@@ -472,8 +476,10 @@ void StreamWrap::Writev(const FunctionCallbackInfo<Value>& args) {
req_wrap->object()->Set(env->bytes_string(),
Number::New(env->isolate(), bytes));
const char* msg = wrap->callbacks()->Error();
- if (msg != nullptr)
+ if (msg != nullptr) {
req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg));
+ wrap->callbacks()->ClearError();
+ }
if (err) {
req_wrap->~WriteWrap();
@@ -536,8 +542,10 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
};
const char* msg = wrap->callbacks()->Error();
- if (msg != nullptr)
+ if (msg != nullptr) {
argv[3] = OneByteString(env->isolate(), msg);
+ wrap->callbacks()->ClearError();
+ }
req_wrap->MakeCallback(env->oncomplete_string(), ARRAY_SIZE(argv), argv);
@@ -592,11 +600,15 @@ void StreamWrap::AfterShutdown(uv_shutdown_t* req, int status) {
}
-const char* StreamWrapCallbacks::Error() {
+const char* StreamWrapCallbacks::Error() const {
return nullptr;
}
+void StreamWrapCallbacks::ClearError() {
+}
+
+
// NOTE: Call to this function could change both `buf`'s and `count`'s
// values, shifting their base and decrementing their length. This is
// required in order to skip the data that was successfully written via