1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Have one call to from_backend() per call to do_telnet_read(),

instead of the previous rate of one per character. In `Flush log
file frequently' mode, the latter was causing excessive slowdown due
to fflush()ing once per byte.

[originally from svn r7076]
This commit is contained in:
Simon Tatham 2007-01-08 18:54:49 +00:00
parent 274f6a60f7
commit bacbc03f9f

View File

@ -254,11 +254,10 @@ typedef struct telnet_tag {
#define SB_DELTA 1024
static void c_write1(Telnet telnet, int c)
static void c_write(Telnet telnet, char *buf, int len)
{
int backlog;
char cc = (char) c;
backlog = from_backend(telnet->frontend, 0, &cc, 1);
backlog = from_backend(telnet->frontend, 0, buf, len);
sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG);
}
@ -541,6 +540,16 @@ static void process_subneg(Telnet telnet)
static void do_telnet_read(Telnet telnet, char *buf, int len)
{
char *outbuf = NULL;
int outbuflen = 0, outbufsize = 0;
#define ADDTOBUF(c) do { \
if (outbuflen >= outbufsize) { \
outbufsize = outbuflen + 256; \
outbuf = sresize(outbuf, outbufsize, char); \
} \
outbuf[outbuflen++] = (c); \
} while (0)
while (len--) {
int c = (unsigned char) *buf++;
@ -554,7 +563,7 @@ static void do_telnet_read(Telnet telnet, char *buf, int len)
telnet->state = SEENIAC;
else {
if (!telnet->in_synch)
c_write1(telnet, c);
ADDTOBUF(c);
#if 1
/* I can't get the F***ing winsock to insert the urgent IAC
@ -591,7 +600,7 @@ static void do_telnet_read(Telnet telnet, char *buf, int len)
} else {
/* ignore everything else; print it if it's IAC */
if (c == IAC) {
c_write1(telnet, c);
ADDTOBUF(c);
}
telnet->state = TOP_LEVEL;
}
@ -641,6 +650,10 @@ static void do_telnet_read(Telnet telnet, char *buf, int len)
break;
}
}
if (outbuflen)
c_write(telnet, outbuf, outbuflen);
sfree(outbuf);
}
static void telnet_log(Plug plug, int type, SockAddr addr, int port,