diff --git a/otherbackends/raw.c b/otherbackends/raw.c index 9c803594..2f099ce3 100644 --- a/otherbackends/raw.c +++ b/otherbackends/raw.c @@ -207,16 +207,14 @@ static void raw_reconfig(Backend *be, Conf *conf) /* * Called to send data down the raw connection. */ -static size_t raw_send(Backend *be, const char *buf, size_t len) +static void raw_send(Backend *be, const char *buf, size_t len) { Raw *raw = container_of(be, Raw, backend); if (raw->s == NULL) - return 0; + return; raw->bufsize = sk_write(raw->s, buf, len); - - return raw->bufsize; } /* diff --git a/otherbackends/rlogin.c b/otherbackends/rlogin.c index 30ad0526..d0da322a 100644 --- a/otherbackends/rlogin.c +++ b/otherbackends/rlogin.c @@ -269,13 +269,13 @@ static void rlogin_reconfig(Backend *be, Conf *conf) /* * Called to send data down the rlogin connection. */ -static size_t rlogin_send(Backend *be, const char *buf, size_t len) +static void rlogin_send(Backend *be, const char *buf, size_t len) { Rlogin *rlogin = container_of(be, Rlogin, backend); bufchain bc; if (rlogin->s == NULL) - return 0; + return; bufchain_init(&bc); bufchain_add(&bc, buf, len); @@ -305,8 +305,6 @@ static size_t rlogin_send(Backend *be, const char *buf, size_t len) } bufchain_clear(&bc); - - return rlogin->bufsize; } /* diff --git a/otherbackends/supdup.c b/otherbackends/supdup.c index e7eff6ee..7111c9a6 100644 --- a/otherbackends/supdup.c +++ b/otherbackends/supdup.c @@ -797,14 +797,14 @@ static void supdup_reconfig(Backend *be, Conf *conf) /* * Called to send data down the Supdup connection. */ -static size_t supdup_send(Backend *be, const char *buf, size_t len) +static void supdup_send(Backend *be, const char *buf, size_t len) { Supdup *supdup = container_of(be, Supdup, backend); char c; int i; if (supdup->s == NULL) - return 0; + return; for (i = 0; i < len; i++) { if (buf[i] == 034) @@ -814,7 +814,6 @@ static size_t supdup_send(Backend *be, const char *buf, size_t len) supdup->bufsize = sk_write(supdup->s, &c, 1); } } - return supdup->bufsize; } /* diff --git a/otherbackends/telnet.c b/otherbackends/telnet.c index 4b784036..15afd82e 100644 --- a/otherbackends/telnet.c +++ b/otherbackends/telnet.c @@ -813,7 +813,7 @@ static void telnet_reconfig(Backend *be, Conf *conf) /* * Called to send data down the Telnet connection. */ -static size_t telnet_send(Backend *be, const char *buf, size_t len) +static void telnet_send(Backend *be, const char *buf, size_t len) { Telnet *telnet = container_of(be, Telnet, backend); unsigned char *p, *end; @@ -824,7 +824,7 @@ static size_t telnet_send(Backend *be, const char *buf, size_t len) #endif if (telnet->s == NULL) - return 0; + return; p = (unsigned char *)buf; end = (unsigned char *)(buf + len); @@ -841,8 +841,6 @@ static size_t telnet_send(Backend *be, const char *buf, size_t len) p++; } } - - return telnet->bufsize; } /* diff --git a/otherbackends/testback.c b/otherbackends/testback.c index 8a158439..4ff6fa16 100644 --- a/otherbackends/testback.c +++ b/otherbackends/testback.c @@ -39,9 +39,10 @@ static char *loop_init(const BackendVtable *, Seat *, Backend **, LogContext *, static void null_free(Backend *); static void loop_free(Backend *); static void null_reconfig(Backend *, Conf *); -static size_t null_send(Backend *, const char *, size_t); -static size_t loop_send(Backend *, const char *, size_t); +static void null_send(Backend *, const char *, size_t); +static void loop_send(Backend *, const char *, size_t); static size_t null_sendbuffer(Backend *); +static size_t loop_sendbuffer(Backend *); static void null_size(Backend *, int, int); static void null_special(Backend *, SessionSpecialCode, int); static const SessionSpecial *null_get_specials(Backend *); @@ -80,7 +81,7 @@ const BackendVtable loop_backend = { .free = loop_free, .reconfig = null_reconfig, .send = loop_send, - .sendbuffer = null_sendbuffer, + .sendbuffer = loop_sendbuffer, .size = null_size, .special = null_special, .get_specials = null_get_specials, @@ -100,6 +101,7 @@ const BackendVtable loop_backend = { struct loop_state { Seat *seat; Backend backend; + size_t sendbuffer; }; static char *null_init(const BackendVtable *vt, Seat *seat, @@ -143,15 +145,14 @@ static void null_reconfig(Backend *be, Conf *conf) { } -static size_t null_send(Backend *be, const char *buf, size_t len) { +static void null_send(Backend *be, const char *buf, size_t len) { - return 0; } -static size_t loop_send(Backend *be, const char *buf, size_t len) { +static void loop_send(Backend *be, const char *buf, size_t len) { struct loop_state *st = container_of(be, struct loop_state, backend); - return seat_output(st->seat, 0, buf, len); + st->sendbuffer = seat_output(st->seat, 0, buf, len); } static size_t null_sendbuffer(Backend *be) { @@ -159,6 +160,12 @@ static size_t null_sendbuffer(Backend *be) { return 0; } +static size_t loop_sendbuffer(Backend *be) { + struct loop_state *st = container_of(be, struct loop_state, backend); + + return st->sendbuffer; +} + static void null_size(Backend *be, int width, int height) { } diff --git a/pscp.c b/pscp.c index a200484f..d759fb4e 100644 --- a/pscp.c +++ b/pscp.c @@ -851,7 +851,8 @@ int scp_send_filedata(char *data, int len) scp_sftp_fileoffset += len; return 0; } else { - int bufsize = backend_send(backend, data, len); + backend_send(backend, data, len); + int bufsize = backend_sendbuffer(backend); /* * If the network transfer is backing up - that is, the diff --git a/putty.h b/putty.h index 382c010d..4492d515 100644 --- a/putty.h +++ b/putty.h @@ -636,9 +636,8 @@ struct BackendVtable { void (*free) (Backend *be); /* Pass in a replacement configuration. */ void (*reconfig) (Backend *be, Conf *conf); - /* send() returns the current amount of buffered data. */ - size_t (*send) (Backend *be, const char *buf, size_t len); - /* sendbuffer() does the same thing but without attempting a send */ + void (*send) (Backend *be, const char *buf, size_t len); + /* sendbuffer() returns the current amount of buffered data */ size_t (*sendbuffer) (Backend *be); void (*size) (Backend *be, int width, int height); void (*special) (Backend *be, SessionSpecialCode code, int arg); @@ -687,8 +686,8 @@ static inline void backend_free(Backend *be) { be->vt->free(be); } static inline void backend_reconfig(Backend *be, Conf *conf) { be->vt->reconfig(be, conf); } -static inline size_t backend_send(Backend *be, const char *buf, size_t len) -{ return be->vt->send(be, buf, len); } +static inline void backend_send(Backend *be, const char *buf, size_t len) +{ be->vt->send(be, buf, len); } static inline size_t backend_sendbuffer(Backend *be) { return be->vt->sendbuffer(be); } static inline void backend_size(Backend *be, int width, int height) diff --git a/ssh/sesschan.c b/ssh/sesschan.c index 7a2062a8..e1496023 100644 --- a/ssh/sesschan.c +++ b/ssh/sesschan.c @@ -270,7 +270,8 @@ static size_t sesschan_send(Channel *chan, bool is_stderr, if (!sess->backend || sess->ignoring_input) return 0; - return backend_send(sess->backend, data, length); + backend_send(sess->backend, data, length); + return backend_sendbuffer(sess->backend); } static void sesschan_send_eof(Channel *chan) diff --git a/ssh/ssh.c b/ssh/ssh.c index 096c8b01..4ad10169 100644 --- a/ssh/ssh.c +++ b/ssh/ssh.c @@ -1003,18 +1003,16 @@ static void ssh_reconfig(Backend *be, Conf *conf) /* * Called to send data down the SSH connection. */ -static size_t ssh_send(Backend *be, const char *buf, size_t len) +static void ssh_send(Backend *be, const char *buf, size_t len) { Ssh *ssh = container_of(be, Ssh, backend); if (ssh == NULL || ssh->s == NULL) - return 0; + return; bufchain_add(&ssh->user_input, buf, len); if (ssh->base_layer) ssh_ppl_got_user_input(ssh->base_layer); - - return backend_sendbuffer(&ssh->backend); } /* diff --git a/sshproxy.c b/sshproxy.c index 955012a8..9c6708ab 100644 --- a/sshproxy.c +++ b/sshproxy.c @@ -106,7 +106,8 @@ static size_t sshproxy_write(Socket *s, const void *data, size_t len) SshProxy *sp = container_of(s, SshProxy, sock); if (!sp->backend) return 0; - return backend_send(sp->backend, data, len); + backend_send(sp->backend, data, len); + return backend_sendbuffer(sp->backend); } static size_t sshproxy_write_oob(Socket *s, const void *data, size_t len) diff --git a/unix/pty.c b/unix/pty.c index 8321f982..e74ebd4b 100644 --- a/unix/pty.c +++ b/unix/pty.c @@ -1367,17 +1367,15 @@ static void pty_try_write(Pty *pty) /* * Called to send data down the pty. */ -static size_t pty_send(Backend *be, const char *buf, size_t len) +static void pty_send(Backend *be, const char *buf, size_t len) { Pty *pty = container_of(be, Pty, backend); if (pty->master_i < 0 || pty->pending_eof) - return 0; /* ignore all writes if fd closed */ + return; /* ignore all writes if fd closed */ bufchain_add(&pty->output_data, buf, len); pty_try_write(pty); - - return bufchain_size(&pty->output_data); } static void pty_close(Pty *pty) diff --git a/unix/serial.c b/unix/serial.c index d17e4cdd..905c1b2d 100644 --- a/unix/serial.c +++ b/unix/serial.c @@ -461,17 +461,15 @@ static void serial_try_write(Serial *serial) /* * Called to send data down the serial connection. */ -static size_t serial_send(Backend *be, const char *buf, size_t len) +static void serial_send(Backend *be, const char *buf, size_t len) { Serial *serial = container_of(be, Serial, backend); if (serial->fd < 0) - return 0; + return; bufchain_add(&serial->output_data, buf, len); serial_try_write(serial); - - return bufchain_size(&serial->output_data); } /* diff --git a/windows/conpty.c b/windows/conpty.c index 843d6725..f2882316 100644 --- a/windows/conpty.c +++ b/windows/conpty.c @@ -287,15 +287,14 @@ static void conpty_reconfig(Backend *be, Conf *conf) { } -static size_t conpty_send(Backend *be, const char *buf, size_t len) +static void conpty_send(Backend *be, const char *buf, size_t len) { ConPTY *conpty = container_of(be, ConPTY, backend); if (conpty->out == NULL) - return 0; + return; conpty->bufsize = handle_write(conpty->out, buf, len); - return conpty->bufsize; } static size_t conpty_sendbuffer(Backend *be) diff --git a/windows/plink.c b/windows/plink.c index 2c68fb63..5bb001be 100644 --- a/windows/plink.c +++ b/windows/plink.c @@ -204,7 +204,8 @@ size_t stdin_gotdata(struct handle *h, const void *data, size_t len, int err) noise_ultralight(NOISE_SOURCE_IOLEN, len); if (backend_connected(backend)) { if (len > 0) { - return backend_send(backend, data, len); + backend_send(backend, data, len); + return backend_sendbuffer(backend); } else { backend_special(backend, SS_EOF, 0); return 0; diff --git a/windows/serial.c b/windows/serial.c index 3d5ea8e5..470c979f 100644 --- a/windows/serial.c +++ b/windows/serial.c @@ -306,15 +306,14 @@ static void serial_reconfig(Backend *be, Conf *conf) /* * Called to send data down the serial connection. */ -static size_t serial_send(Backend *be, const char *buf, size_t len) +static void serial_send(Backend *be, const char *buf, size_t len) { Serial *serial = container_of(be, Serial, backend); if (serial->out == NULL) - return 0; + return; serial->bufsize = handle_write(serial->out, buf, len); - return serial->bufsize; } /*