libuv/libuv — pull request #50 by mpenick (2014-12-09 22:51:36+00:00)
Title: Fix for uv_async data race

I ran into a data race when using the uv_async_send(). The problem is here: https://github.com/joyent/libuv/blob/v0.10/src/unix/async.c#L78-L79.

```c
if (!h->pending) continue;
/* If the sending thread sets "pending" to 1 it could get trampled here
* causing an async send event to be missed.
*/
h->pending = 0;
```

I ran all tests and also ran the async benchmarks (on a 4 core x64 proc.) I didn't see any performance regression. I only have the single architecture so others might need to run it on all supported architectures. I removed the `#else` branch in `uv__async_make_pending()` because `uv__async_event()` doesn't have a counterpart without a data race.

+1 adding a cross platform atomics library to libuv that can "dog fooded" for these type of things. :)

Note: The problem also exists on the v1.x branch. It should be straightforward to port.