alexcrichton / tokio-curl

Asynchronous HTTP client built on libcurl
Apache License 2.0
110 stars 15 forks source link

Half the time main never terminates with simple curl request. #11

Closed glademiller closed 7 years ago

glademiller commented 7 years ago

nightly-x86_64-pc-windows-msvc (default) rustc 1.15.0-nightly (8f02c429a 2016-12-15)

The following code snippet will run and the program will fail to exit about every other run if not more.

extern crate tokio_core;
extern crate tokio_curl;
extern crate futures;
extern crate curl;

use tokio_core::reactor::Core;
use curl::easy::Easy;
use tokio_curl::Session;
use futures::Future;
fn main() {
    let mut lp = Core::new().unwrap();
    let session = Session::new(lp.handle());
    let mut req = Easy::new();
    req.custom_request("GET").unwrap();
    req.url("https://www.rust-lang.org").unwrap();
    let res = session.perform(req)
        .map(|mut resp| {
            let status_code = resp.response_code().ok().unwrap_or(0);
            status_code
        });
    let result = lp.run(res);
    println!("{:?}", result);
}
glademiller commented 7 years ago

Verified that I was unable to reproduce this on Linux.

glademiller commented 7 years ago

I minimized the error case down to. This may be an issue for another project tokio-core or futures.


extern crate tokio_core;
extern crate tokio_curl;
extern crate futures;
extern crate curl;

use tokio_core::reactor::Core;
use curl::easy::Easy;
use tokio_curl::Session;
use futures::Future;
fn main() {
    let mut lp = Core::new().unwrap();
    let session = Session::new(lp.handle());
    let mut req = Easy::new();
    req.custom_request("GET").unwrap();
    req.url("https://www.rust-lang.org").unwrap();
    let res = session.perform(req)
        .map(|mut resp| {
            let status_code = resp.response_code().ok().unwrap_or(0);
            println!("{}", status_code);
        });
}
alexcrichton commented 7 years ago

Thanks for the report! Looks like this was indeed a Windows-specific problem to this library due to a typo in https://github.com/tokio-rs/tokio-curl/commit/78f6d5d933eb9ffee58e45177710e466673be9ba. Should be fixed now though!

glademiller commented 7 years ago

Thank you for the quick fix.