From 53413598b6a0f23e64680f69abbb7b2ab80d8fb7 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 8 Jan 2010 22:18:18 -0800 Subject: [PATCH] Fix another problem with the EIO interface Should call eio_poll() when given a done_poll signal as well. Bug report and test case by Kris Zyp --- src/node.cc | 21 ++++++++++++++++++--- test/mjsunit/test-eio-race4.js | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 test/mjsunit/test-eio-race4.js diff --git a/src/node.cc b/src/node.cc index 14144a5..3080266 100644 --- a/src/node.cc +++ b/src/node.cc @@ -70,7 +70,12 @@ static void DoPoll(EV_P_ ev_idle *watcher, int revents) { assert(watcher == &eio_poller); assert(revents == EV_IDLE); - if (eio_poll() != -1) ev_idle_stop(EV_DEFAULT_UC_ watcher); + //printf("eio_poller\n"); + + if (eio_poll() != -1) { + //printf("eio_poller stop\n"); + ev_idle_stop(EV_DEFAULT_UC_ watcher); + } } @@ -79,7 +84,12 @@ static void WantPollNotifier(EV_P_ ev_async *watcher, int revents) { assert(watcher == &eio_want_poll_notifier); assert(revents == EV_ASYNC); - if (eio_poll() == -1) ev_idle_start(EV_DEFAULT_UC_ &eio_poller); + //printf("want poll notifier\n"); + + if (eio_poll() == -1) { + //printf("eio_poller start\n"); + ev_idle_start(EV_DEFAULT_UC_ &eio_poller); + } } @@ -87,7 +97,12 @@ static void DonePollNotifier(EV_P_ ev_async *watcher, int revents) { assert(watcher == &eio_done_poll_notifier); assert(revents == EV_ASYNC); - ev_idle_stop(EV_DEFAULT_UC_ &eio_poller); + //printf("done poll notifier\n"); + + if (eio_poll() != -1) { + //printf("eio_poller stop\n"); + ev_idle_stop(EV_DEFAULT_UC_ &eio_poller); + } } diff --git a/test/mjsunit/test-eio-race4.js b/test/mjsunit/test-eio-race4.js new file mode 100644 index 0000000..93039e1 --- /dev/null +++ b/test/mjsunit/test-eio-race4.js @@ -0,0 +1,19 @@ +process.mixin(require("./common")); + +var N = 100; +var j = 0; + +for (var i = 0; i < N; i++) { + posix.stat("does-not-exist-" + i) // these files don't exist + .addErrback(function (e) { + j++; // only makes it to about 17 + puts("finish " + j); + }) + .addCallback(function () { + puts("won't be called"); + }); +} + +process.addListener("exit", function () { + assert.equal(N, j); +}); -- 2.7.4