summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2013-09-21 00:17:22 +0800
committerMatt Johnston <matt@ucc.asn.au>2013-09-21 00:17:22 +0800
commitdffb33cecf3eca78d1a852c0b3d7c137b6775db2 (patch)
treed04da0119536d051d476d6701ec885c5a5e33791
parente7917c16c95e878aa33ff32144044b72ee41a11f (diff)
Improve EOF handling for half-close. Patch from Catalin Patulea
Fixes the situation $ ./dbclient root@1.2.3.4 'cat; echo foo' ^D <no output>
-rw-r--r--common-channel.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/common-channel.c b/common-channel.c
index 8b7369c..2068904 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -307,7 +307,9 @@ static void check_close(struct Channel *channel) {
return;
}
- if (channel->recv_eof && !write_pending(channel)) {
+ if ((channel->recv_eof && !write_pending(channel))
+ /* have a server "session" and child has exited */
+ || (channel->type->check_close && close_allowed)) {
close_chan_fd(channel, channel->writefd, SHUT_WR);
}
@@ -336,6 +338,7 @@ static void check_close(struct Channel *channel) {
/* And if we can't receive any more data from them either, close up */
if (channel->readfd == FD_CLOSED
+ && channel->writefd == FD_CLOSED
&& (ERRFD_IS_WRITE(channel) || channel->errfd == FD_CLOSED)
&& !channel->sent_close
&& close_allowed