diff options
author | Ryo Nakamura <upa@haeena.net> | 2022-12-04 21:32:48 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2022-12-04 21:32:48 +0900 |
commit | e1d14623f41eb82c5acb90c17ba5c62b7d798bbe (patch) | |
tree | 8b6ab42639c4d252c0b15e971f7da5075de83fe8 /src | |
parent | 3b794ab51b04cd82f84f5b820f57267695066d80 (diff) |
set TCP_NODELAY by default and introduce -N option to disable it
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 9 | ||||
-rw-r--r-- | src/ssh.c | 6 | ||||
-rw-r--r-- | src/ssh.h | 1 |
3 files changed, 14 insertions, 2 deletions
@@ -82,7 +82,7 @@ void stop_copy_threads(int sig) void usage(bool print_help) { printf("mscp v" VERSION ": copy files over multiple ssh connections\n" "\n" - "Usage: mscp [vqDCHdh] [-n nr_conns] [-m coremask]\n" + "Usage: mscp [vqDCHdNh] [-n nr_conns] [-m coremask]\n" " [-s min_chunk_sz] [-S max_chunk_sz] [-a nr_ahead] [-b buf_sz]\n" " [-l login_name] [-p port] [-i identity_file]\n" " [-c cipher_spec] [-M hmac_spec] source ... target\n" @@ -111,6 +111,7 @@ void usage(bool print_help) { " -C enable compression on libssh\n" " -H disable hostkey check\n" " -d increment ssh debug output level\n" + " -N disable tcp nodelay (default on)\n" " -h print this help\n" "\n"); } @@ -229,6 +230,7 @@ int main(int argc, char **argv) char ch; memset(&opts, 0, sizeof(opts)); + opts.nodelay = 1; memset(&m, 0, sizeof(m)); INIT_LIST_HEAD(&m.file_list); INIT_LIST_HEAD(&m.chunk_list); @@ -238,7 +240,7 @@ int main(int argc, char **argv) m.nr_threads = (int)(nr_cpus() / 2); m.nr_threads = m.nr_threads == 0 ? 1 : m.nr_threads; - while ((ch = getopt(argc, argv, "n:m:s:S:a:b:vqDl:p:i:c:M:CHdh")) != -1) { + while ((ch = getopt(argc, argv, "n:m:s:S:a:b:vqDl:p:i:c:M:CHdNh")) != -1) { switch (ch) { case 'n': m.nr_threads = atoi(optarg); @@ -327,6 +329,9 @@ int main(int argc, char **argv) case 'd': opts.debuglevel++; break; + case 'N': + opts.nodelay = 0; + break; case 'h': usage(true); return 0; @@ -62,6 +62,12 @@ static int ssh_set_opts(ssh_session ssh, struct ssh_opts *opts) return -1; } + if (opts->nodelay && + ssh_options_set(ssh, SSH_OPTIONS_NODELAY, &opts->nodelay) < 0) { + pr_err("failed to set nodelay\n"); + return -1; + } + return 0; } @@ -13,6 +13,7 @@ struct ssh_opts { char *cipher; /* -c */ char *hmac; /* -M */ int compress; /* -C */ + int nodelay; /* -N */ int debuglevel; /* -v */ bool no_hostkey_check; /* -H */ |