hookio/hook.io — pull request #142 by bacchusrx (2011-12-20 20:26:26+00:00)
Title: Unix socket support

This pull request is mostly for discussion purposes, at this stage. I've implemented basic support for starting hooks on UNIX sockets, using the existing hook-socket configuration option. This branch includes basic tests and some extensions to `test/helpers/macros.js` to support them.

I haven't yet tested `.spawn()` with hook-socket.

The main issue is that in node 0.6.x with libuv since August, there's an outstanding issue where a pipe can be bound multiple times without throwing EADDRINUSE. That issue is described here: https://github.com/joyent/libuv/issues/158. Essentially, the previous implementation used a lock to ensure that a pipe couldn't be bound multiple times, but this was removed because Solaris doesn't support flock().

Because of this, `.start()` fails to work properly when using hook-socket because the `.listen()` call never fails, and so it never faills back to `.connect()`. (It works fine if you don't use `.start()` but use `.listen()` and `.connect()` explicitly.)

I initially attempted to work around this by implementing a lock file at the hook.io level but it was messy and so I just ended up forking and patching libuv to restore the previous behaviour. That code is here: https://github.com/bacchusrx/libuv/compare/master...pipe-flock

Anyway, I'd like to not have to maintain separate forks of libuv and hook.io just to get this functionality, so I'm opening this pull request to see what everyone wants to do to get this supported officially.