Bug 1471201 - Increase webdriver HTTPD Keep-Alive timeout to 90s. r?automatedtester
Increasing geckodriver's Keep-Alive timeout duration to 90
seconds, from the default five seconds, will reduce the number of
HTTP connections a persistent-enabled client will have to make,
potentially boosting performance.
In more recent hyper versions the default is 90 seconds, which
means we can get rid of this line when hyper is upgraded.
This will help mitigate https://github.com/mozilla/geckodriver/issues/1304
but not fundamentally resolve it, due to a standard library bug in
Python 2.7's urllib.
MozReview-Commit-ID: 98AFDQgWfpw
--- a/testing/webdriver/src/server.rs
+++ b/testing/webdriver/src/server.rs
@@ -1,14 +1,15 @@
use std::io::Read;
use std::marker::PhantomData;
use std::net::SocketAddr;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Mutex;
use std::thread;
+use std::time::Duration;
use hyper::header::{ContentType, CacheControl, CacheDirective};
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
use hyper::method::Method;
use hyper::Result;
use hyper::server::{Handler, Listening, Request, Response, Server};
use hyper::status::StatusCode;
use hyper::uri::RequestUri::AbsolutePath;
@@ -234,29 +235,32 @@ impl<U: WebDriverExtensionRoute> Handler
res.send(&resp_body.as_bytes()).unwrap();
}
_ => {}
}
}
}
-pub fn start<T, U>(address: SocketAddr,
- handler: T,
- extension_routes: &[(Method, &str, U)])
- -> Result<Listening>
- where T: 'static + WebDriverHandler<U>,
- U: 'static + WebDriverExtensionRoute
+pub fn start<T, U>(
+ address: SocketAddr,
+ handler: T,
+ extension_routes: &[(Method, &str, U)],
+) -> Result<Listening>
+where
+ T: 'static + WebDriverHandler<U>,
+ U: 'static + WebDriverExtensionRoute,
{
let (msg_send, msg_recv) = channel();
let api = WebDriverHttpApi::new(extension_routes);
let http_handler = HttpHandler::new(api, msg_send);
- let server = try!(Server::http(address));
+ let mut server = Server::http(address)?;
+ server.keep_alive(Some(Duration::from_secs(90)));
let builder = thread::Builder::new().name("webdriver dispatcher".to_string());
- try!(builder.spawn(move || {
+ builder.spawn(move || {
let mut dispatcher = Dispatcher::new(handler);
dispatcher.run(msg_recv);
- }));
+ })?;
server.handle(http_handler)
}