Date: Thu, 24 Nov 2016 15:23:52 -0700 From: Ian Lepore <ian@freebsd.org> To: Jakub Wojciech Klama <jceel@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r309121 - head/usr.sbin/bhyve Message-ID: <1480026232.1889.63.camel@freebsd.org> In-Reply-To: <201611242216.uAOMGIi0065703@repo.freebsd.org> References: <201611242216.uAOMGIi0065703@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 2016-11-24 at 22:16 +0000, Jakub Wojciech Klama wrote: > Author: jceel > Date: Thu Nov 24 22:16:18 2016 > New Revision: 309121 > URL: https://svnweb.freebsd.org/changeset/base/309121 > > Log: > virtio_console: handle short writes to an Unix domain socket > gracefully. > > writev() can do a short write. Retrying it results in a very > convoluted > and complex code, so we iterate over iovec and do regular > stream_write() > instead. > Doesn't pwritev(2) simplify iterating to handle short writes? -- Ian > Approved by: trasz > Sponsored by: iXsystems, Inc. > > Modified: > head/usr.sbin/bhyve/pci_virtio_console.c > > Modified: head/usr.sbin/bhyve/pci_virtio_console.c > ===================================================================== > ========= > --- head/usr.sbin/bhyve/pci_virtio_console.c Thu Nov 24 > 21:53:42 2016 (r309120) > +++ head/usr.sbin/bhyve/pci_virtio_console.c Thu Nov 24 > 22:16:18 2016 (r309121) > @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); > #include "pci_emul.h" > #include "virtio.h" > #include "mevent.h" > +#include "sockstream.h" > > #define VTCON_RINGSZ 64 > #define VTCON_MAXPORTS 16 > @@ -425,16 +426,21 @@ pci_vtcon_sock_tx(struct pci_vtcon_port > int niov) > { > struct pci_vtcon_sock *sock; > - int ret; > + int i, ret; > > sock = (struct pci_vtcon_sock *)arg; > > if (sock->vss_conn_fd == -1) > return; > > - ret = writev(sock->vss_conn_fd, iov, niov); > + for (i = 0; i < niov; i++) { > + ret = stream_write(sock->vss_conn_fd, > iov[i].iov_base, > + iov[i].iov_len); > + if (ret <= 0) > + break; > + } > > - if (ret < 0 && errno != EWOULDBLOCK) { > + if (ret <= 0) { > mevent_delete_close(sock->vss_conn_evp); > sock->vss_conn_fd = -1; > sock->vss_open = false; >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1480026232.1889.63.camel>