FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fd_to_send needs to be cleared if *any* data was sent · scream/node@a936340 · GitHub

Repository navigation

Commit a936340

Browse files
committed
fd_to_send needs to be cleared if *any* data was sent
1 parent 464ced4 commit a936340

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎src/node_io_watcher.cc‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ void IOWatcher::Dump() {
367367
DEBUG_PRINT("<%d> got fd to send: %d", io->watcher_.fd, fd_to_send);
368368
assert(fd_to_send >= 0);
369369
}
370+
// Already set this to null. We will readd the fd later if there was
371+
// an error.
372+
bucket->Set(fd_sym, Null());
370373
}
371374
}
372375

@@ -410,6 +413,14 @@ void IOWatcher::Dump() {
410413
written);
411414

412415
if (written < 0) {
416+
417+
// Some sort of error. Must set the fd_to_send back in the bucket.
418+
if (fd_to_send >= 0) {
419+
Local<Value> bucket_v = watcher->Get(first_bucket_sym);
420+
assert(bucket_v->IsObject());
421+
bucket_v->ToObject()->Set(fd_sym, Integer::New(fd_to_send));
422+
}
423+
413424
// Allow EAGAIN.
414425
// TODO: handle EMSGSIZE after sendmsg().
415426
if (errno == EAGAIN) {
@@ -471,10 +482,6 @@ void IOWatcher::Dump() {
471482
// serialized onto a buffer.
472483
size_t bucket_len = Buffer::Length(data_v->ToObject());
473484

474-
if (unix_socket && bucket->Has(fd_sym)) {
475-
bucket->Set(fd_sym, Null());
476-
}
477-
478485
DEBUG_PRINT("<%d,%ld> bucket_len: %ld, offset: %ld",
479486
io->watcher_.fd,
480487
bucket_index,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL