Skip to content

Commit

Permalink
[sshsession] Enable NODELAY
Browse files Browse the repository at this point in the history
Enable NODELAY by default our ssh usage, which include interactive
console clients and and sftp server, benefit greatly in terms of
performance.

Fixes canonical#167.
  • Loading branch information
albaguirre committed Mar 2, 2018
1 parent f44c3fc commit 4804087
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ssh/ssh_session.cpp
Expand Up @@ -93,12 +93,14 @@ mp::SSHSession::SSHSession(const std::string& host, int port, const SSHKeyProvid
if (session == nullptr)
throw std::runtime_error("Could not allocate ssh session");

const long timeout = 1;
const long timeout{1};
const int nodelay{1};

SSH::throw_on_error(ssh_options_set, session, SSH_OPTIONS_HOST, host.c_str());
SSH::throw_on_error(ssh_options_set, session, SSH_OPTIONS_PORT, &port);
SSH::throw_on_error(ssh_options_set, session, SSH_OPTIONS_USER, "ubuntu");
SSH::throw_on_error(ssh_options_set, session, SSH_OPTIONS_TIMEOUT, &timeout);
SSH::throw_on_error(ssh_options_set, session, SSH_OPTIONS_NODELAY, &nodelay);
SSH::throw_on_error(ssh_connect, session);
if (key_provider)
SSH::throw_on_error(ssh_userauth_publickey, session, nullptr, key_provider->private_key());
Expand Down

0 comments on commit 4804087

Please sign in to comment.