aboutsummaryrefslogtreecommitdiff
path: root/src/uv-unix.c
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2011-07-20 23:06:44 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2011-07-20 23:06:44 +0200
commit332bbecd19725ca4aeb66a9ab0efc4b1d9863d70 (patch)
tree024f79b03e83729e7affd21f76eb85a679ad5132 /src/uv-unix.c
parent685c083c792c651b92629e60e90ddde672c3f287 (diff)
downloadlibuv-332bbecd19725ca4aeb66a9ab0efc4b1d9863d70.tar.gz
libuv-332bbecd19725ca4aeb66a9ab0efc4b1d9863d70.zip
uv-unix: defer uv_pipe_connect callback to next tick
Diffstat (limited to 'src/uv-unix.c')
-rw-r--r--src/uv-unix.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/uv-unix.c b/src/uv-unix.c
index 3c3b42de..a2b9d377 100644
--- a/src/uv-unix.c
+++ b/src/uv-unix.c
@@ -877,6 +877,8 @@ static void uv__stream_io(EV_P_ ev_io* watcher, int revents) {
if (stream->connect_req) {
uv__stream_connect(stream);
} else {
+ assert(revents & (EV_READ | EV_WRITE));
+
if (revents & EV_READ) {
uv__read((uv_stream_t*)stream);
}
@@ -1909,15 +1911,16 @@ int uv_pipe_connect(uv_connect_t* req,
status = 0;
out:
- uv__req_init((uv_req_t*)req);
+ handle->delayed_error = status; /* Passed to callback. */
+ handle->connect_req = req;
req->handle = (uv_stream_t*)handle;
req->type = UV_CONNECT;
req->cb = cb;
ngx_queue_init(&req->queue);
- if (cb) {
- cb(req, status);
- }
+ /* Run callback on next tick. */
+ ev_feed_event(EV_DEFAULT_ &handle->read_watcher, EV_CUSTOM);
+ assert(ev_is_pending(&handle->read_watcher));
/* Mimic the Windows pipe implementation, always
* return 0 and let the callback handle errors.