diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-04-19 21:39:30 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-19 21:39:30 -0700 |
| commit | 5bfb260cf87b4907f885877d5ac4e819edb970db (patch) | |
| tree | 47e32efe5943f689e925561b06541e9778ee4fe3 /src | |
| parent | 7b6e7ebe73b5f046faa81406ed58866364f6cfee (diff) | |
| download | rust-5bfb260cf87b4907f885877d5ac4e819edb970db.tar.gz rust-5bfb260cf87b4907f885877d5ac4e819edb970db.zip | |
rustuv: Fix a tcp connect timeout bug on windows
When a uv_tcp_t is closed in libuv, it will still invoke the pending connect_cb, and I thought that it would always call it with ECANCELED, but it turns out that sometimes we'll get a different error code instead. Handle this case by checking to see if the request's data is NULL and bail out if so (the timeout expired).
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustuv/net.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index cbda25485c7..69d978b2433 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -270,7 +270,14 @@ impl TcpWatcher { let req = Request::wrap(req); if status == uvll::ECANCELED { return } - let cx: &mut Ctx = unsafe { req.get_data() }; + // Apparently on windows when the handle is closed this callback may + // not be invoked with ECANCELED but rather another error code. + // Either ways, if the data is null, then our timeout has expired + // and there's nothing we can do. + let data = unsafe { uvll::get_data_for_req(req.handle) }; + if data.is_null() { return } + + let cx: &mut Ctx = unsafe { &mut *(data as *mut Ctx) }; cx.status = status; match cx.timer { Some(ref mut t) => t.stop(), |
