From c9dca9269fc444e3808532bb4716726f6f136e57 Mon Sep 17 00:00:00 2001 From: angt Date: Thu, 29 Oct 2015 18:18:52 +0100 Subject: [PATCH] Do not use writev() for now --- glorytun.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/glorytun.c b/glorytun.c index f78f1b7..d0f9bbe 100644 --- a/glorytun.c +++ b/glorytun.c @@ -239,6 +239,7 @@ static ssize_t fd_write (int fd, const void *data, size_t size) return ret; } +/* static ssize_t fd_writev (int fd, const struct iovec *iov, int count) { if (!count) @@ -256,6 +257,7 @@ static ssize_t fd_writev (int fd, const struct iovec *iov, int count) return ret; } +*/ enum option_type { option_flag, @@ -471,14 +473,9 @@ int main (int argc, char **argv) if (fds[0].revents & POLLOUT) fds[0].events = POLLIN; - struct iovec iov[16]; - size_t count; - - uint8_t *data = sock.recv.read; - - for (count=0; countsize) break; - iov[count].iov_base = data; - iov[count].iov_len = ip_size; - - data += ip_size; - } - - if (count) { - ssize_t r = fd_writev(fds[0].fd, iov, count); + ssize_t r = fd_write(fds[0].fd, sock.recv.read, ip_size); if (!r) return 2; @@ -501,8 +491,10 @@ int main (int argc, char **argv) if (r==-1) fds[0].events = POLLIN|POLLOUT; - if (r>0) - sock.recv.read += r; + if (r<0) + break; + + sock.recv.read += r; } }