JuliaLang/julia — pull request #2694 by amitmurthy (2013-03-26 21:54:16+00:00)
Title: RFC: Support uv_poll* set of functions

Support for uv_poll* functions is required for usage of libraries like libCURL and openssl which read/write to the sockets directly, while using libuv only for event notification.

I modeled support for uv_poll* function on TimeoutAsyncWork, i.e., the new uv based sleep() implementation.

Issues
--------.
- In stream.jl, The expected behavior of ```poll_socket(s::PollSocket, events::Int32, timeout_ms::Int32) ``` is to wait on both a socket event (read/write) and a timeout event. Upon either event occurring it should return after cancelling the other event.

Currently the timeout is not implemented since I don't know how to wait for either of 2 events, whichever happens earlier. poll_socket as currently implemented ignores timeout_ms and only waits on the socket events.

- The malloc'ed uv_poll_t struct is not being freed. Looking at the sleep() function, I could not see an explicit free of the handle created in jl_make_timer(). Where do these handles get released?

- Declaring portable socket types as shown below
```
@unix_only typealias PollSocket Int32
@windows_only typealias PollSocket Ptr{Void}
```
resulted in the build process hanging on my machine. Hence have commented out the same in the patch. This patch will not work on 64-bit Windows.

Have tested the code on my 32-bit Ubuntu 12.10 machine. Managed to get it working with libCURL.