Mercurial > dropbear
changeset 529:da6340a60039
- Try to write out as much as we can
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 26 Feb 2009 12:18:11 +0000 |
parents | ce104c8b0be1 |
children | 22a0d8355c2c 164b7c2cd5df |
files | common-session.c packet.c packet.h |
diffstat | 3 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/common-session.c Wed Nov 12 13:13:00 2008 +0000 +++ b/common-session.c Thu Feb 26 12:18:11 2009 +0000 @@ -189,7 +189,7 @@ /* process session socket's incoming/outgoing data */ if (ses.sock_out != -1) { if (FD_ISSET(ses.sock_out, &writefd) && !isempty(&ses.writequeue)) { - write_packet(); + write_packets(); } }
--- a/packet.c Wed Nov 12 13:13:00 2008 +0000 +++ b/packet.c Thu Feb 26 12:18:11 2009 +0000 @@ -46,14 +46,16 @@ static void buf_compress(buffer * dest, buffer * src, unsigned int len); #endif -/* non-blocking function writing out a current encrypted packet */ -void write_packet() { +/* non-blocking function writing out a current encrypted packet. Returns + * DROPBEAR_SUCCESS if entire packet was written, DROPBEAR_FAILURE + * otherwise */ +static int write_packet() { int len, written; + int ret = DROPBEAR_FAILURE; buffer * writebuf = NULL; TRACE(("enter write_packet")) - dropbear_assert(!isempty(&ses.writequeue)); /* Get the next buffer in the queue of encrypted packets to write*/ writebuf = (buffer*)examine(&ses.writequeue); @@ -84,12 +86,19 @@ dequeue(&ses.writequeue); buf_free(writebuf); writebuf = NULL; + ret = DROPBEAR_SUCCESS; } else { /* More packet left to write, leave it in the queue for later */ buf_incrpos(writebuf, written); } TRACE(("leave write_packet")) + return ret; +} + +void write_packets() { + /* keep writing packets while we can. */ + while (!isempty(&ses.writequeue) && write_packet() == DROPBEAR_SUCCESS) {} } /* Non-blocking function reading available portion of a packet into the