- djm@cvs.openbsd.org 2011/01/16 12:05:59

[clientloop.c]
     a couple more tweaks to the post-close protocol 1 stderr/stdout flush:
     now that we use atomicio(), convert them from while loops to if statements
     add test and cast to compile cleanly with -Wsigned
This commit is contained in:
Damien Miller 2011-01-16 23:18:33 +11:00
parent 6fb6fd5662
commit cfd6e4f57f
2 changed files with 14 additions and 11 deletions

View File

@ -11,6 +11,11 @@
[sshconnect.c]
reset the SIGPIPE handler when forking to execute child processes;
ok dtucker@
- djm@cvs.openbsd.org 2011/01/16 12:05:59
[clientloop.c]
a couple more tweaks to the post-close protocol 1 stderr/stdout flush:
now that we use atomicio(), convert them from while loops to if statements
add test and cast to compile cleanly with -Wsigned
20110114
- OpenBSD CVS Sync

View File

@ -1,4 +1,4 @@
/* $OpenBSD: clientloop.c,v 1.230 2011/01/16 11:50:05 djm Exp $ */
/* $OpenBSD: clientloop.c,v 1.231 2011/01/16 12:05:59 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1590,25 +1590,23 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
}
/* Output any buffered data for stdout. */
while (buffer_len(&stdout_buffer) > 0) {
if (buffer_len(&stdout_buffer) > 0) {
len = atomicio(vwrite, fileno(stdout),
buffer_ptr(&stdout_buffer), buffer_len(&stdout_buffer));
if (len != buffer_len(&stdout_buffer)) {
if (len < 0 || (u_int)len != buffer_len(&stdout_buffer))
error("Write failed flushing stdout buffer.");
break;
}
buffer_consume(&stdout_buffer, len);
else
buffer_consume(&stdout_buffer, len);
}
/* Output any buffered data for stderr. */
while (buffer_len(&stderr_buffer) > 0) {
if (buffer_len(&stderr_buffer) > 0) {
len = atomicio(vwrite, fileno(stderr),
buffer_ptr(&stderr_buffer), buffer_len(&stderr_buffer));
if (len != buffer_len(&stderr_buffer)) {
if (len < 0 || (u_int)len != buffer_len(&stderr_buffer))
error("Write failed flushing stderr buffer.");
break;
}
buffer_consume(&stderr_buffer, len);
else
buffer_consume(&stderr_buffer, len);
}
/* Clear and free any buffers. */