From 2a5d1ac68e3c28951b9b7df25aa41dc959f74bf2 Mon Sep 17 00:00:00 2001 From: Nate Straz Date: Tue, 8 Apr 2008 14:42:02 +0000 Subject: Increase the buffer size we use to read output from the host. This should help get all output before we exit. There is still a race if the cmdexit packet returns before all output where we could truncate output. --- qarsh.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'qarsh.c') diff --git a/qarsh.c b/qarsh.c index cf80d96..de963fb 100644 --- a/qarsh.c +++ b/qarsh.c @@ -45,6 +45,7 @@ #include "hbeat.h" #define QARSH_MINPORT 5010 +#define QARSH_BUFSIZE 4096 /* Globals */ @@ -264,8 +265,8 @@ run_remote_cmd(char *cmdline) "fcntl stdin O_NONBLOCK failed, %d: %s\n", errno, strerror(errno)); } - buf = malloc(1024); - memset(buf, 0, 1024); + buf = malloc(QARSH_BUFSIZE); + memset(buf, 0, QARSH_BUFSIZE); hbeat(qarsh_hb); cmd_finished = 0; @@ -278,7 +279,7 @@ run_remote_cmd(char *cmdline) timeout.tv_nsec = 0; } testfds = readfds; - memset(buf, 0, 1024); + memset(buf, 0, QARSH_BUFSIZE); nset = pselect(FD_SETSIZE, &testfds, NULL, NULL, &timeout, &pselect_sigmask); @@ -314,7 +315,7 @@ run_remote_cmd(char *cmdline) hbeat_setstate(qarsh_hb, HOST_ALIVE); if (nset && FD_ISSET(fileno(stdin), &testfds)) { - bufsize = read(fileno(stdin), buf, 1024); + bufsize = read(fileno(stdin), buf, QARSH_BUFSIZE); if (bufsize > 0) { write(c_in, buf, bufsize); } else if (bufsize == 0) { @@ -326,7 +327,7 @@ run_remote_cmd(char *cmdline) nset--; } if (nset && c_out && FD_ISSET(c_out, &testfds)) { - bufsize = read(c_out, buf, 1024); + bufsize = read(c_out, buf, QARSH_BUFSIZE); if (bufsize > 0) { write(fileno(stdout), buf, bufsize); } else if (bufsize == 0) { @@ -337,7 +338,7 @@ run_remote_cmd(char *cmdline) nset--; } if (nset && c_err && FD_ISSET(c_err, &testfds)) { - bufsize = read(c_err, buf, 1024); + bufsize = read(c_err, buf, QARSH_BUFSIZE); if (bufsize > 0) { write(fileno(stderr), buf, bufsize); } else if (bufsize == 0) { -- cgit