From a93634007a0c5366d415782c2a1f164a6d7ecbc5 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 19 Nov 2010 23:05:13 -0800 Subject: [PATCH] fd_to_send needs to be cleared if *any* data was sent --- src/node_io_watcher.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/node_io_watcher.cc b/src/node_io_watcher.cc index 33e544340f..5aec2d306e 100644 --- a/src/node_io_watcher.cc +++ b/src/node_io_watcher.cc @@ -367,6 +367,9 @@ void IOWatcher::Dump() { DEBUG_PRINT("<%d> got fd to send: %d", io->watcher_.fd, fd_to_send); assert(fd_to_send >= 0); } + // Already set this to null. We will readd the fd later if there was + // an error. + bucket->Set(fd_sym, Null()); } } @@ -410,6 +413,14 @@ void IOWatcher::Dump() { written); if (written < 0) { + + // Some sort of error. Must set the fd_to_send back in the bucket. + if (fd_to_send >= 0) { + Local bucket_v = watcher->Get(first_bucket_sym); + assert(bucket_v->IsObject()); + bucket_v->ToObject()->Set(fd_sym, Integer::New(fd_to_send)); + } + // Allow EAGAIN. // TODO: handle EMSGSIZE after sendmsg(). if (errno == EAGAIN) { @@ -471,10 +482,6 @@ void IOWatcher::Dump() { // serialized onto a buffer. size_t bucket_len = Buffer::Length(data_v->ToObject()); - if (unix_socket && bucket->Has(fd_sym)) { - bucket->Set(fd_sym, Null()); - } - DEBUG_PRINT("<%d,%ld> bucket_len: %ld, offset: %ld", io->watcher_.fd, bucket_index,