mirror of
https://github.com/clearml/dropbear
synced 2025-01-31 10:57:01 +00:00
Fix "Avoid queueing into circbuffer when the channel is about to close"
which broken handling EAGAIN/EINTR
This commit is contained in:
parent
ee353847be
commit
a3049d6433
@ -445,9 +445,10 @@ static int writechannel_fallback(struct Channel* channel, int fd, circbuffer *cb
|
|||||||
close_chan_fd(channel, fd, SHUT_WR);
|
close_chan_fd(channel, fd, SHUT_WR);
|
||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cbuf_incrread(cbuf, written);
|
||||||
|
channel->recvdonelen += written;
|
||||||
}
|
}
|
||||||
cbuf_incrread(cbuf, written);
|
|
||||||
channel->recvdonelen += written;
|
|
||||||
return DROPBEAR_SUCCESS;
|
return DROPBEAR_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif /* !HAVE_WRITEV */
|
#endif /* !HAVE_WRITEV */
|
||||||
@ -460,7 +461,7 @@ static int writechannel_writev(struct Channel* channel, int fd, circbuffer *cbuf
|
|||||||
unsigned char *circ_p1, *circ_p2;
|
unsigned char *circ_p1, *circ_p2;
|
||||||
unsigned int circ_len1, circ_len2;
|
unsigned int circ_len1, circ_len2;
|
||||||
int io_count = 0;
|
int io_count = 0;
|
||||||
int cbuf_written;
|
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
|
|
||||||
cbuf_readptrs(cbuf, &circ_p1, &circ_len1, &circ_p2, &circ_len2);
|
cbuf_readptrs(cbuf, &circ_p1, &circ_len1, &circ_p2, &circ_len2);
|
||||||
@ -508,14 +509,14 @@ static int writechannel_writev(struct Channel* channel, int fd, circbuffer *cbuf
|
|||||||
close_chan_fd(channel, fd, SHUT_WR);
|
close_chan_fd(channel, fd, SHUT_WR);
|
||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
int cbuf_written = MIN(circ_len1+circ_len2, (unsigned int)written);
|
||||||
|
cbuf_incrread(cbuf, cbuf_written);
|
||||||
|
if (morelen) {
|
||||||
|
*morelen = written - cbuf_written;
|
||||||
|
}
|
||||||
|
channel->recvdonelen += written;
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf_written = MIN(circ_len1+circ_len2, (unsigned int)written);
|
|
||||||
cbuf_incrread(cbuf, cbuf_written);
|
|
||||||
if (morelen) {
|
|
||||||
*morelen = written - cbuf_written;
|
|
||||||
}
|
|
||||||
channel->recvdonelen += written;
|
|
||||||
return DROPBEAR_SUCCESS;
|
return DROPBEAR_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_WRITEV */
|
#endif /* HAVE_WRITEV */
|
||||||
|
Loading…
Reference in New Issue
Block a user