paddybyers/node — Issue #14: eio does not support multiple loops
Author: paddybyers
Created: 2011-11-04 15:24:36+00:00
State: open

[uv-eio.c](https://github.com/paddybyers/node/blob/master/deps/uv/src/unix/uv-eio.c) contains this:

> /* TODO remove me! */
> static uv_loop_t* main_loop;

This is because the two poll callbacks `uv_eio_want_poll` and `uv_eio_done_poll` are called asynchronously without any context, and it is not possible to determine which loop the events are associated with. Normally, this isn't a problem, but it becomes a problem if an application wants to have multiple active loops in a single process.

Support for multiple instances is sought for the Android port, and I'm now running into this problem.

My thought was to put the required information into the `eio_req` via a new `poll_data` field, and for this field to be populated as required whenever the calling application constructs the `eio_req`.

The proposed changes are [here](https://github.com/paddybyers/node/commit/926beb154e6f401c9b3543de6deeedaab4adc415).

This has been tested with multiple simultaneous node instances in a single process and seems to be working OK.