diff options
author | Matt Johnston <matt@ucc.asn.au> | 2013-03-23 23:16:06 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2013-03-23 23:16:06 +0800 |
commit | 5996c3824c52425c2d4f3d7cb69f0c9fa81a33b8 (patch) | |
tree | e3b73be4387ad1f8b8e23b6b4d0d6a81081a36c6 /common-channel.c | |
parent | c172fb3b326ec796a1e81656548653f188a8d62c (diff) |
Add ~. and ~^Z handling to exit/suspend dbclient
Diffstat (limited to 'common-channel.c')
-rw-r--r-- | common-channel.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/common-channel.c b/common-channel.c index 9328a2e..05b9d11 100644 --- a/common-channel.c +++ b/common-channel.c @@ -643,6 +643,7 @@ static void send_msg_channel_data(struct Channel *channel, int isextended) { /* read the data */ len = read(fd, buf_getwriteptr(ses.writepayload, maxlen), maxlen); + if (len <= 0) { if (len == 0 || errno != EINTR) { /* This will also get hit in the case of EAGAIN. The only @@ -650,12 +651,22 @@ static void send_msg_channel_data(struct Channel *channel, int isextended) { in which case it can be treated the same as EOF */ close_chan_fd(channel, fd, SHUT_RD); } - ses.writepayload->len = ses.writepayload->pos = 0; + buf_setpos(ses.writepayload, 0); + buf_setlen(ses.writepayload, 0); TRACE(("leave send_msg_channel_data: len %d read err %d or EOF for fd %d", len, errno, fd)) return; } + if (channel->read_mangler) { + channel->read_mangler(channel, buf_getwriteptr(ses.writepayload, len), &len); + if (len == 0) { + buf_setpos(ses.writepayload, 0); + buf_setlen(ses.writepayload, 0); + return; + } + } + TRACE(("send_msg_channel_data: len %d fd %d", len, fd)) buf_incrwritepos(ses.writepayload, len); /* ... real size here */ |