projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Oops, fix that fix. TranslateKey can return <0 and it needs to be
[u/mdw/putty]
/
raw.c
diff --git
a/raw.c
b/raw.c
index
6106176
..
4bed83c
100644
(file)
--- a/
raw.c
+++ b/
raw.c
@@
-11,25
+11,26
@@
#define TRUE 1
#endif
#define TRUE 1
#endif
+#define RAW_MAX_BACKLOG 4096
+
static Socket s = NULL;
static Socket s = NULL;
+static int raw_bufsize;
static void raw_size(void);
static void raw_size(void);
-static int sb_opt, sb_len;
-static char *sb_buf = NULL;
-static int sb_size = 0;
-#define SB_DELTA 1024
-
static void c_write(char *buf, int len)
{
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,
int calling_back)
{
}
static int raw_closing(Plug plug, char *error_msg, int error_code,
int calling_back)
{
- sk_close(s);
- s = NULL;
+ if (s) {
+ sk_close(s);
+ s = NULL;
+ }
if (error_msg) {
/* A socket error has occurred. */
connection_fatal(error_msg);
if (error_msg) {
/* A socket error has occurred. */
connection_fatal(error_msg);
@@
-48,7
+49,8
@@
static int raw_receive(Plug plug, int urgent, char *data, int len)
*
* Returns an error message, or NULL on success.
*
*
* Returns an error message, or NULL on success.
*
- * Also places the canonical host name into `realhost'.
+ * Also places the canonical host name into `realhost'. It must be
+ * freed by the caller.
*/
static char *raw_init(char *host, int port, char **realhost)
{
*/
static char *raw_init(char *host, int port, char **realhost)
{
@@
-85,13
+87,22
@@
static char *raw_init(char *host, int port, char **realhost)
/*
* Called to send data down the raw connection.
*/
/*
* 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)
if (s == NULL)
- return;
+ return 0;
+
+ raw_bufsize = sk_write(s, buf, len);
+
+ return raw_bufsize;
+}
- sk_write(s, buf, len);
+/*
+ * Called to query the current socket sendability status.
+ */
+static int raw_sendbuffer(void)
+{
+ return raw_bufsize;
}
/*
}
/*
@@
-122,6
+133,11
@@
static int raw_sendok(void)
return 1;
}
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)
static int raw_ldisc(int option)
{
if (option == LD_EDIT || option == LD_ECHO)
@@
-132,10
+148,12
@@
static int raw_ldisc(int option)
Backend raw_backend = {
raw_init,
raw_send,
Backend raw_backend = {
raw_init,
raw_send,
+ raw_sendbuffer,
raw_size,
raw_special,
raw_socket,
raw_sendok,
raw_ldisc,
raw_size,
raw_special,
raw_socket,
raw_sendok,
raw_ldisc,
+ raw_unthrottle,
1
};
1
};