mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-14 09:37:34 -05:00
Extensive changes that _should_ fix the socket buffering problems,
by ceasing to listen on input channels if the corresponding output channel isn't accepting data. Has had basic check-I-didn't-actually- break-anything-too-badly testing, but hasn't been genuinely tested in stress conditions (because concocting stress conditions is non- trivial). [originally from svn r1198]
This commit is contained in:
27
raw.c
27
raw.c
@ -11,13 +11,17 @@
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define RAW_MAX_BACKLOG 4096
|
||||
|
||||
static Socket s = NULL;
|
||||
static int raw_bufsize;
|
||||
|
||||
static void raw_size(void);
|
||||
|
||||
static void c_write(char *buf, int len)
|
||||
{
|
||||
from_backend(0, buf, len);
|
||||
int backlog = from_backend(0, buf, len);
|
||||
sk_set_frozen(s, backlog > RAW_MAX_BACKLOG);
|
||||
}
|
||||
|
||||
static int raw_closing(Plug plug, char *error_msg, int error_code,
|
||||
@ -83,13 +87,23 @@ static char *raw_init(char *host, int port, char **realhost)
|
||||
/*
|
||||
* Called to send data down the raw connection.
|
||||
*/
|
||||
static void raw_send(char *buf, int len)
|
||||
static int raw_send(char *buf, int len)
|
||||
{
|
||||
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
sk_write(s, buf, len);
|
||||
raw_bufsize = sk_write(s, buf, len);
|
||||
|
||||
return raw_bufsize;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called to query the current socket sendability status.
|
||||
*/
|
||||
static int raw_sendbuffer(void)
|
||||
{
|
||||
return raw_bufsize;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -120,6 +134,11 @@ static int raw_sendok(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void raw_unthrottle(int backlog)
|
||||
{
|
||||
sk_set_frozen(s, backlog > RAW_MAX_BACKLOG);
|
||||
}
|
||||
|
||||
static int raw_ldisc(int option)
|
||||
{
|
||||
if (option == LD_EDIT || option == LD_ECHO)
|
||||
@ -130,10 +149,12 @@ static int raw_ldisc(int option)
|
||||
Backend raw_backend = {
|
||||
raw_init,
|
||||
raw_send,
|
||||
raw_sendbuffer,
|
||||
raw_size,
|
||||
raw_special,
|
||||
raw_socket,
|
||||
raw_sendok,
|
||||
raw_ldisc,
|
||||
raw_unthrottle,
|
||||
1
|
||||
};
|
||||
|
Reference in New Issue
Block a user