From 5996c3824c52425c2d4f3d7cb69f0c9fa81a33b8 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Sat, 23 Mar 2013 23:16:06 +0800 Subject: Add ~. and ~^Z handling to exit/suspend dbclient --- common-channel.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'common-channel.c') 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 */ -- cgit v1.2.3