Browse Source

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 <kriszyp@gmail.com>
v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
53413598b6
  1. 21
      src/node.cc
  2. 19
      test/mjsunit/test-eio-race4.js

21
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);
}
}

19
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);
});
Loading…
Cancel
Save