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
5673d8fe28
commit
65feaeaf88
@ -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