paddybyers/node — Issue #15: uv_eio_init calls eio_init multiple times
Author: paddybyers
Created: 2011-11-04 16:10:11+00:00
State: open

[uv-eio.c](https://github.com/paddybyers/node/blob/master/deps/uv/src/unix/uv-eio.c#L103) calls eio_init once for each 'loop'.

However, if more than one `loop` is initialised in any given process, `eio_init` will be called more than once, which is forbidden.

Normally this is not a problem, but it becomes a problem in applications that wish to have multiple loops in a single process. This behaviour is now sought for the Android port.

One solution - which assumes that pthreads are unconditionally available - is [here](https://github.com/paddybyers/node/commit/f3617604a6f7ae4e137711381a5f5fc604eb1c40).

This is perhaps OK, or perhaps the dependency on `pthread_once` needs to be abstracted to support those unix platforms that don't support this.

On the other hand, the principal thread abstraction is in eio/xthread.h, and eio already has multiple mutexes, so I would have thought that this could be implemented more naturally in eio itself, so eio_init guards itself against multiple calls in the same process. Suggestions welcomed.