mirror of
https://github.com/clearml/dropbear
synced 2025-02-01 19:34:11 +00:00
Passes most test cases now
--HG-- branch : channel-fix extra : convert_revision : 5a5f398411a7a3baa9472daa80fea0574fbd8a9a
This commit is contained in:
parent
786ea39ac4
commit
cc340d9cdc
@ -263,10 +263,12 @@ static void check_close(struct Channel *channel) {
|
||||
channel->writebuf,
|
||||
channel->writebuf ? 0 : cbuf_getused(channel->extrabuf)))
|
||||
|
||||
if (!channel->sent_close
|
||||
&& channel->writefd == FD_CLOSED
|
||||
&& (channel->errfd == FD_CLOSED || channel->extrabuf == NULL)) {
|
||||
send_msg_channel_close(channel);
|
||||
/* A bit of a hack for closing up server session channels */
|
||||
if (channel->writefd >= 0
|
||||
&& channel->type->check_close
|
||||
&& channel->type->check_close(channel)) {
|
||||
TRACE(("channel->type->check_close got hit"))
|
||||
close_chan_fd(channel, channel->writefd, SHUT_WR);
|
||||
}
|
||||
|
||||
if (channel->recv_close && !write_pending(channel)) {
|
||||
@ -278,31 +280,15 @@ static void check_close(struct Channel *channel) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// The only use of check_close is "return channel->writefd == -1;" for a server
|
||||
// chansession. Should be able to handle that with just the general
|
||||
// socket close handling...?
|
||||
if (channel->type->check_close) {
|
||||
if (channel->type->check_close(channel)) {
|
||||
close_write_fd(channel);
|
||||
close_read_fd(channel, channel->readfd);
|
||||
close_read_fd(channel, channel->errfd);
|
||||
}
|
||||
if (channel->recv_eof && !write_pending(channel)) {
|
||||
close_chan_fd(channel, channel->writefd, SHUT_WR);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!channel->sent_eof
|
||||
&& channel->readfd == FD_CLOSED
|
||||
&& (channel->extrabuf != NULL || channel->errfd == FD_CLOSED)) {
|
||||
send_msg_channel_eof(channel);
|
||||
}
|
||||
|
||||
if (!channel->sent_close
|
||||
&& channel->writefd == FD_CLOSED
|
||||
&& channel->readfd == FD_CLOSED
|
||||
&& (channel->extrabuf != NULL || channel->errfd == FD_CLOSED)) {
|
||||
send_msg_channel_close(channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -395,13 +381,6 @@ static void writechannel(struct Channel* channel, int fd, circbuffer *cbuf) {
|
||||
cbuf_incrread(cbuf, len);
|
||||
channel->recvdonelen += len;
|
||||
|
||||
/* We're closing out */
|
||||
if (channel->recv_eof && cbuf_getused(cbuf) == 0) {
|
||||
TRACE(("leave writechannel"))
|
||||
close_chan_fd(channel, fd, SHUT_WR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Window adjust handling */
|
||||
if (channel->recvdonelen >= RECV_WINDOWEXTEND) {
|
||||
/* Set it back to max window */
|
||||
|
@ -65,6 +65,11 @@ static void get_termmodes(struct ChanSess *chansess);
|
||||
/* required to clear environment */
|
||||
extern char** environ;
|
||||
|
||||
static int sesscheckclose(struct Channel *channel) {
|
||||
struct ChanSess *chansess = (struct ChanSess*)channel->typedata;
|
||||
return chansess->exit.exitpid != -1;
|
||||
}
|
||||
|
||||
/* Handler for childs exiting, store the state for return to the client */
|
||||
|
||||
/* There's a particular race we have to watch out for: if the forked child
|
||||
@ -962,7 +967,7 @@ const struct ChanType svrchansess = {
|
||||
0, /* sepfds */
|
||||
"session", /* name */
|
||||
newchansess, /* inithandler */
|
||||
NULL, /* checkclosehandler */
|
||||
sesscheckclose, /* checkclosehandler */
|
||||
chansessionrequest, /* reqhandler */
|
||||
closechansess, /* closehandler */
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user