mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +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:
parent
274f6a60f7
commit
bacbc03f9f
23
telnet.c
23
telnet.c
@ -254,11 +254,10 @@ typedef struct telnet_tag {
|
|||||||
|
|
||||||
#define SB_DELTA 1024
|
#define SB_DELTA 1024
|
||||||
|
|
||||||
static void c_write1(Telnet telnet, int c)
|
static void c_write(Telnet telnet, char *buf, int len)
|
||||||
{
|
{
|
||||||
int backlog;
|
int backlog;
|
||||||
char cc = (char) c;
|
backlog = from_backend(telnet->frontend, 0, buf, len);
|
||||||
backlog = from_backend(telnet->frontend, 0, &cc, 1);
|
|
||||||
sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG);
|
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)
|
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--) {
|
while (len--) {
|
||||||
int c = (unsigned char) *buf++;
|
int c = (unsigned char) *buf++;
|
||||||
@ -554,7 +563,7 @@ static void do_telnet_read(Telnet telnet, char *buf, int len)
|
|||||||
telnet->state = SEENIAC;
|
telnet->state = SEENIAC;
|
||||||
else {
|
else {
|
||||||
if (!telnet->in_synch)
|
if (!telnet->in_synch)
|
||||||
c_write1(telnet, c);
|
ADDTOBUF(c);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
/* I can't get the F***ing winsock to insert the urgent IAC
|
/* 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 {
|
} else {
|
||||||
/* ignore everything else; print it if it's IAC */
|
/* ignore everything else; print it if it's IAC */
|
||||||
if (c == IAC) {
|
if (c == IAC) {
|
||||||
c_write1(telnet, c);
|
ADDTOBUF(c);
|
||||||
}
|
}
|
||||||
telnet->state = TOP_LEVEL;
|
telnet->state = TOP_LEVEL;
|
||||||
}
|
}
|
||||||
@ -641,6 +650,10 @@ static void do_telnet_read(Telnet telnet, char *buf, int len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outbuflen)
|
||||||
|
c_write(telnet, outbuf, outbuflen);
|
||||||
|
sfree(outbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void telnet_log(Plug plug, int type, SockAddr addr, int port,
|
static void telnet_log(Plug plug, int type, SockAddr addr, int port,
|
||||||
|
Loading…
Reference in New Issue
Block a user