mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 07:29:32 +00:00
Respect IOV_MAX if defined
Solaris has a pitiful maximum writev vector size of only 16, so the ping request at initial startup destroyed this call and broke things immediately. Reimplement stream_writev_cb() to respect IOV_MAX and break the writev() calls into chunks as necessary. Care was taken to return the correct values as necessary so the EAGAIN handling logic can determine where to resume the writev call the next time around. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
This commit is contained in:
parent
143a1df24e
commit
bdfd6c234b
@ -23,6 +23,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
@ -340,7 +341,31 @@ static ssize_t stream_write_cb(RedsStream *s, const void *buf, size_t size)
|
||||
|
||||
static ssize_t stream_writev_cb(RedsStream *s, const struct iovec *iov, int iovcnt)
|
||||
{
|
||||
return writev(s->socket, iov, iovcnt);
|
||||
ssize_t ret = 0;
|
||||
do {
|
||||
int tosend;
|
||||
ssize_t n, expected = 0;
|
||||
int i;
|
||||
#ifdef IOV_MAX
|
||||
tosend = MIN(iovcnt, IOV_MAX);
|
||||
#else
|
||||
tosend = iovcnt;
|
||||
#endif
|
||||
for (i = 0; i < tosend; i++) {
|
||||
expected += iov[i].iov_len;
|
||||
}
|
||||
n = writev(s->socket, iov, tosend);
|
||||
if (n <= expected) {
|
||||
if (n > 0)
|
||||
ret += n;
|
||||
return ret == 0 ? n : ret;
|
||||
}
|
||||
ret += n;
|
||||
iov += tosend;
|
||||
iovcnt -= tosend;
|
||||
} while(iovcnt > 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t stream_read_cb(RedsStream *s, void *buf, size_t size)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user