Bug 1461608 - [geckodriver] Reduce stream read timeout for Marionette handshake to 10s. r=ato

By default the stream read timeout is set to None, which means if
geckodriver successfully connects to a port, which doesn't send any
data, it waits forever.

Given that handshake data should be received immediately reduce the
read timeout on supported platforms to 10s. This would still allow
slower builds (eg. ASAN) to send the Marionette handshake.

--HG--
extra : rebase_source : be351c9d15b950c0e493e5a1809296764db75c20
This commit is contained in:
Henrik Skupin 2018-09-03 16:40:08 +02:00
Родитель c24e592dc9
Коммит 3eb9b34997
1 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -1118,16 +1118,42 @@ impl MarionetteConnection {
}
}
debug!(
"Connection established on {}:{}. Waiting for Marionette handshake",
DEFAULT_HOST, self.port,
);
let data = self.handshake()?;
self.session.application_type = Some(data.application_type);
self.session.protocol = Some(data.protocol);
debug!("Connected to Marionette on {}:{}", DEFAULT_HOST, self.port);
debug!("Connected to Marionette");
Ok(())
}
fn handshake(&mut self) -> WebDriverResult<MarionetteHandshake> {
let resp = self.read_resp()?;
let resp = (match self.stream.as_mut().unwrap().read_timeout() {
Ok(timeout) => {
// If platform supports changing the read timeout of the stream,
// use a short one only for the handshake with Marionette.
self.stream
.as_mut()
.unwrap()
.set_read_timeout(Some(time::Duration::from_secs(10)))
.ok();
let data = self.read_resp();
self.stream.as_mut().unwrap().set_read_timeout(timeout).ok();
data
}
_ => self.read_resp(),
}).or_else(|e| {
Err(WebDriverError::new(
ErrorStatus::UnknownError,
format!("Socket timeout reading Marionette handshake data: {}", e),
))
})?;
let data = serde_json::from_str::<MarionetteHandshake>(&resp)?;
if data.application_type != "gecko" {