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. Approved by: trasz Sponsored by: iXsystems, Inc.
This commit is contained in:
parent
962094d52a
commit
d286418ee6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=309121
@ -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 *port, void *arg, struct iovec *iov,
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user