paddybyers / node

evented I/O for v8 javascript
http://nodejs.org/
Other
91 stars 24 forks source link

uv_eio_init calls eio_init multiple times #15

Open paddybyers opened 12 years ago

paddybyers commented 12 years ago

uv-eio.c 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.

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.