diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-11-12 16:24:53 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-11-18 16:47:38 -0800 |
commit | fa556a142512ab932b7359760e5e4585e4e035b6 (patch) | |
tree | 00a1ab1f741fb84190d14c99a2b90a9592cbcc2c /src | |
parent | a6d84253824694b6e6ec148ec57cb344727d3a84 (diff) | |
download | node-new-fa556a142512ab932b7359760e5e4585e4e035b6.tar.gz |
Add callback to socket.write(), fix test-sendfds
Diffstat (limited to 'src')
-rw-r--r-- | src/node_io_watcher.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_io_watcher.cc b/src/node_io_watcher.cc index 3f85076279..62c5646463 100644 --- a/src/node_io_watcher.cc +++ b/src/node_io_watcher.cc @@ -38,6 +38,7 @@ static Persistent<String> is_unix_socket_sym; static Persistent<String> first_bucket_sym; static Persistent<String> last_bucket_sym; static Persistent<String> queue_size_sym; +static Persistent<String> callback_sym; void IOWatcher::Initialize(Handle<Object> target) { @@ -73,6 +74,7 @@ void IOWatcher::Initialize(Handle<Object> target) { is_unix_socket_sym = NODE_PSYMBOL("isUnixSocket"); data_sym = NODE_PSYMBOL("data"); encoding_sym = NODE_PSYMBOL("encoding"); + callback_sym = NODE_PSYMBOL("callback"); ev_prepare_init(&dumper, IOWatcher::Dump); @@ -497,6 +499,17 @@ void IOWatcher::Dump() { written -= bucket_len - offset; + Local<Value> bucket_callback_v = bucket->Get(callback_sym); + if (bucket_callback_v->IsFunction()) { + Local<Function> bucket_callback = + Local<Function>::Cast(bucket_callback_v); + TryCatch try_catch; + bucket_callback->Call(io->handle_, 0, NULL); + if (try_catch.HasCaught()) { + FatalException(try_catch); + } + } + // Offset is now zero watcher->Set(offset_sym, Integer::NewFromUnsigned(0)); } |