summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2022-01-22 00:49:34 +0000
committerDamien Miller <djm@mindrot.org>2022-01-25 12:18:35 +1100
commitb30d32159dc3c7052f4bfdf36357996c905af739 (patch)
tree25d0f90b2823952c57e6d72f4dad0c4aec5d6592 /clientloop.c
parenta1a8efeaaa9cccb15cdc0a2bd7c347a149a3a7e3 (diff)
downloadopenssh-git-b30d32159dc3c7052f4bfdf36357996c905af739.tar.gz
upstream: add a ssh_packet_process_read() function that reads from
a fd directly into the transport input buffer. Use this in the client and server mainloops to avoid unnecessary copying. It also lets us use a more greedy read size without penalty. Yields a 2-3% performance gain on cipher-speed.sh (in a fairly unscientific test tbf) feedback dtucker@ ok markus@ OpenBSD-Commit-ID: df4112125bf79d8e38e79a77113e1b373078e632
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/clientloop.c b/clientloop.c
index 5145f011..fd190980 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.377 2022/01/21 07:04:19 djm Exp $ */
+/* $OpenBSD: clientloop.c,v 1.378 2022/01/22 00:49:34 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -630,40 +630,25 @@ client_suspend_self(struct sshbuf *bin, struct sshbuf *bout, struct sshbuf *berr
static void
client_process_net_input(struct ssh *ssh)
{
- char buf[SSH_IOBUFSZ];
- int len;
+ int r;
/*
* Read input from the server, and add any such data to the buffer of
* the packet subsystem.
*/
schedule_server_alive_check();
- /* Read as much as possible. */
- len = read(connection_in, buf, sizeof(buf));
- if (len == 0) {
- /* Received EOF. The remote host has closed the connection. */
- quit_message("Connection to %.300s closed by remote host.",
- host);
- return;
- }
- /*
- * There is a kernel bug on Solaris that causes poll to
- * sometimes wake up even though there is no data available.
- */
- if (len == -1 &&
- (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
- len = 0;
-
- if (len == -1) {
- /*
- * An error has encountered. Perhaps there is a
- * network problem.
- */
- quit_message("Read from remote host %s: %s",
- host, strerror(errno));
- return;
+ if ((r = ssh_packet_process_read(ssh, connection_in)) == 0)
+ return; /* success */
+ if (r == SSH_ERR_SYSTEM_ERROR) {
+ if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)
+ return;
+ if (errno == EPIPE) {
+ quit_message("Connection to %s closed by remote host.",
+ host);
+ return;
+ }
}
- ssh_packet_process_incoming(ssh, buf, len);
+ quit_message("Read from remote host %s: %s", host, ssh_err(r));
}
static void